From: Brian G. <bri...@ea...> - 2013-05-29 15:45:54
|
The C code is threaded, whereas Gustaf's Tcl script is not. I wonder if the threads are helping or hurting... Also, won't this cause problems?: /* Allocate s. */ s = Tcl_NewStringObj("", 0); Tcl_IncrRefCount(s); /* Load stdin into s. */ load_file(stdin, s); Shouldn't the IncrRefCount come after the load_file? -Brian On May 29, 2013, at 5:26 AM, Frédéric Bonnet <fre...@fr...> wrote: > Seems OK to me -- The benchmark's C version is based on Tcl's RE engine > and ranks #2 on their list, far ahead of Perl/Python/PHP/Ruby. > > > http://benchmarksgame.alioth.debian.org/u32/program.php?test=regexdna&lang=gcc&id=1 > > ############################################# > # notes > > gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3 > > Is this a C program or is this a Tcl program? > > ############################################# > # regex-dna C gcc program source code > > /* The Computer Language Benchmarks Game > * http://benchmarksgame.alioth.debian.org/ > contributed by Paul Serice > */ > > #include <sys/types.h> > #include <pthread.h> > #include <errno.h> > #include <stdio.h> > #include <stdlib.h> > #include <string.h> > #include <glib.h> > #include <tcl.h> > > ############################################# > > > > > Le 29/05/2013 11:46, Gustaf Neumann a écrit : >> Dear all. >> >> Here is a benchmark, where Tcl looks very well -- unless i >> have goofed up my >> implementation, but the output is correct. Interestingly Tcl >> 8.6 is on this test >> better than Tcl 8.5 and Perl 5.12), Python (3.3.2), PHP and >> Ruby (1.8 and 2.0). >> All tests are made on a recent Imac (2.9 GHz Intel i5 under >> Mac OS X 10.8.3). >> >> The test sources and various implementations are here: >> http://benchmarksgame.alioth.debian.org/u32/benchmark.php?test=regexdna&lang=all&id=2&data=u32 >> >> The implementation is below and straightforward. >> >> -gustaf neumann >> >> ====================================================================== >> Tcl 8.6 >> % time tclsh ~/scripts/regex-dna.tcl < ~/scripts/regexdna-input5000000.txt >> real 0m5.295s >> user 0m4.463s >> sys 0m0.826s >> >> Tcl 8.5 >> % time tclsh8.5 ~/scripts/regex-dna.tcl < ~/scripts/regexdna-input5000000.txt >> real 0m7.975s >> user 0m6.784s >> sys 0m1.180s >> >> Perl 5 (v5.12.4) regex-dna Perl #2 >> % time perl ~/scripts/regex-dna2.pl < ~/scripts/regexdna-input5000000.txt >> real 0m9.473s >> user 0m28.609s >> sys 0m0.578s >> >> Python (Python 3.3.2) regex-dna Python 3 #5 >> % time python3.3 ~/scripts/regex-dna.py < ~/scripts/regexdna-input5000000.txt >> real 0m16.228s >> user 0m15.538s >> sys 0m0.671s >> >> PHP (PHP 5.3.15) regex-dna PHP #3 >> % time php -n -d memory_limit=512M ~/scripts/regex-dna.php < ~/scripts/regexdna-input5000000.txt >> real 0m19.123s >> user 0m18.706s >> sys 0m0.389s >> >> Ruby (ruby 2.0.0p195) regex-dna Ruby 2.0 #2 >> time ruby ~/scripts/regex-dna.rb < ~/scripts/regexdna-input5000000.txt >> real 0m22.703s >> user 0m22.286s >> sys 0m0.398s >> >> Ruby (ruby 1.8.7) regex-dna Ruby 2.0 #2 >> time ruby ~/scripts/regex-dna.rb < ~/scripts/regexdna-input5000000.txt >> real 0m35.371s >> user 0m34.894s >> sys 0m0.483s >> >> Perl 5 (v5.12.4) regex-dna Perl #4 >> % time perl ~/scripts/regex-dna.pl < ~/scripts/regexdna-input5000000.txt >> real 0m52.197s >> user 0m51.990s >> sys 0m0.176s >> >> ====================================================================== >> set content [read stdin] >> set inputLength [string length $content] >> >> regsub -all -lineanchor {^>[^\n]*$} [string tolower $content] "" content >> regsub -all {\n} $content "" content >> set contentLength [string length $content] >> >> set patterns { >> agggtaaa|tttaccct >> [cgt]gggtaaa|tttaccc[acg] >> a[act]ggtaaa|tttacc[agt]t >> ag[act]gtaaa|tttac[agt]ct >> agg[act]taaa|ttta[agt]cct >> aggg[acg]aaa|ttt[cgt]ccct >> agggt[cgt]aa|tt[acg]accct >> agggta[cgt]a|t[acg]taccct >> agggtaa[cgt]|[acg]ttaccct >> } >> foreach pattern $patterns { >> puts "$pattern [regexp -all $pattern $content]" >> } >> foreach {from to} { >> b (c|g|t) >> d (a|g|t) >> h (a|c|t) >> k (g|t) >> m (a|c) >> n (a|c|g|t) >> r (a|g) >> s (c|t) >> v (a|c|g) >> w (a|t) >> y (c|t) >> } { >> regsub -all $from $content $to content >> } >> puts $inputLength\n$contentLength\n[string length $content] >> ====================================================================== >> >> Output >> ====================================================================== >> agggtaaa|tttaccct 356 >> [cgt]gggtaaa|tttaccc[acg] 1250 >> a[act]ggtaaa|tttacc[agt]t 4252 >> ag[act]gtaaa|tttac[agt]ct 2894 >> agg[act]taaa|ttta[agt]cct 5435 >> aggg[acg]aaa|ttt[cgt]ccct 1537 >> agggt[cgt]aa|tt[acg]accct 1431 >> agggta[cgt]a|t[acg]taccct 1608 >> agggtaa[cgt]|[acg]ttaccct 2178 >> 50833411 >> 50000000 >> 66800214 >> ====================================================================== >> >> >> >> ------------------------------------------------------------------------------ >> Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET >> Get 100% visibility into your production application - at no cost. >> Code-level diagnostics for performance bottlenecks with <2% overhead >> Download for free and get started troubleshooting in minutes. >> http://p.sf.net/sfu/appdyn_d2d_ap1 >> _______________________________________________ >> Tcl-Core mailing list >> Tcl...@li... >> https://lists.sourceforge.net/lists/listinfo/tcl-core >> > > > ------------------------------------------------------------------------------ > Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET > Get 100% visibility into your production application - at no cost. > Code-level diagnostics for performance bottlenecks with <2% overhead > Download for free and get started troubleshooting in minutes. > http://p.sf.net/sfu/appdyn_d2d_ap1 > _______________________________________________ > Tcl-Core mailing list > Tcl...@li... > https://lists.sourceforge.net/lists/listinfo/tcl-core |