# HG changeset patch # User Christian Urban # Date 1602058135 -3600 # Node ID a10430cb797c0e259c1c4523954032fd1fa2efc1 # Parent 939c10745a3af7706a9f5654ba72b210a0df6c89 updated diff -r 939c10745a3a -r a10430cb797c data.sty --- a/data.sty Tue Oct 06 13:32:00 2020 +0100 +++ b/data.sty Wed Oct 07 09:08:55 2020 +0100 @@ -101,6 +101,22 @@ 27 22.430 \end{filecontents} +% Dart, example (a*)*b +\begin{filecontents}{re-dart.data} +20 0.042 +21 0.084 +22 0.190 +23 0.340 +24 0.678 +25 1.369 +26 2.700 +27 5.462 +28 10.908 +29 21.725 +30 43.492 +\end{filecontents} + + % Java 8, example (a*)*b \begin{filecontents}{re-java.data} 5 0.00298 diff -r 939c10745a3a -r a10430cb797c progs/catastrophic/catastrophic.dart --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/progs/catastrophic/catastrophic.dart Wed Oct 07 09:08:55 2020 +0100 @@ -0,0 +1,23 @@ +/// A case of catastrophic backtracking in Dart +///--------------------------------------------- +/// example provided by Martin Todorov +/// +/// regex: (a*)*b +/// strings: aa...a +/// +/// run with +/// +/// dart catastrophic.dart n + + +main(List args) { + final n = int.parse(args[0]); + final evilRegex = RegExp("(a*)*b"); + + for(int i = 1; i <= n; i++) { + final toMatch = "a" * i; + final stopwatch = Stopwatch()..start(); + evilRegex.hasMatch(toMatch); + print("$i a's matched in ${stopwatch.elapsed}"); + } +} diff -r 939c10745a3a -r a10430cb797c slides/slides02.pdf Binary file slides/slides02.pdf has changed diff -r 939c10745a3a -r a10430cb797c slides/slides02.tex --- a/slides/slides02.tex Tue Oct 06 13:32:00 2020 +0100 +++ b/slides/slides02.tex Wed Oct 07 09:08:55 2020 +0100 @@ -20,7 +20,7 @@ numbers=none, xleftmargin=0mm} -\pgfplotsset{compat=1.12} +\pgfplotsset{compat=1.17} \newcommand{\bl}[1]{\textcolor{blue}{#1}} @@ -887,13 +887,14 @@ axis lines=left, width=9cm, height=5.5cm, - legend entries={Java 8, Python, JavaScript, Swift}, + legend entries={Java 8,Python,JavaScript,Swift,Dart}, legend pos=north west, legend cell align=left] \addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data}; \addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data}; \addplot[red,mark=*, mark options={fill=white}] table {re-js.data}; \addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data}; +\addplot[brown,mark=*, mark options={fill=white}] table {re-dart.data}; \end{axis} \end{tikzpicture} \end{center}