Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions run-benchmarks.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
'Python PyPy3' => 'pypy3 python/benchmark.py',
'Ruby' => 'ruby ruby/benchmark.rb',
'Rust' => 'rust/target/release/benchmark',
'Tcl' => 'tclsh tcl/benchmark.tcl',
];

echo '- Build' . PHP_EOL;
Expand Down
7 changes: 7 additions & 0 deletions tcl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Tcl Regex Benchmark

## How to run

```sh
tclsh benchmark.tcl <filename>
```
14 changes: 14 additions & 0 deletions tcl/benchmark.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace path {::tcl::mathop ::tcl::mathfunc}

proc measure {data pat} {
set start [clock microseconds]
set match_count [regexp -all $pat $data]
set elapsed [/ [- [clock microseconds] $start] 1e3]
puts [format {%.3f - %u} $elapsed $match_count]
}

set data [read [open [lindex $argv 0]]]

measure $data {[\w\.+-]+@[\w\.-]+\.[\w\.-]+}
measure $data {[\w]+://[^/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?}
measure $data {(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])}