Permalink
Browse files

Squashed 'vendor/underscore-tcl/' content from commit 63e1c98

git-subtree-dir: vendor/underscore-tcl
git-subtree-split: 63e1c988ff8c8632edc729f28bfdd314e4e03b83
  • Loading branch information...
0 parents commit 649b2b64aaf92bc8f974fce2ea15086762707f90 @arthurschreiber committed Nov 18, 2012
Showing with 666 additions and 0 deletions.
  1. +34 −0 benchmarks/each.tcl
  2. +21 −0 benchmarks/map.tcl
  3. +1 −0 pkgIndex.tcl
  4. +348 −0 spec/underscore_spec.tcl
  5. +262 −0 underscore.tcl
@@ -0,0 +1,34 @@
+set auto_path [concat [file join [file dirname [info script]] ".."] $auto_path]
+
+package require underscore
+
+set numbers [list]
+for {set i 0} {$i < 100} { incr i } { lappend numbers $i }
+
+puts "foreach with empty body"
+puts [time {
+ foreach num $numbers {
+ # Do nothing...
+ }
+} 1000]
+
+puts "_::each with empty body"
+puts [time {
+ _::each $numbers {{num} {
+ # Do nothing...
+ }}
+} 1000]
+
+puts "foreach with expression"
+puts [time {
+ foreach num $numbers {
+ expr { $num * $num }
+ }
+} 1000]
+
+puts "_::each with expression"
+puts [time {
+ _::each $numbers {{num} {
+ expr { $num * $num }
+ }}
+} 1000]
@@ -0,0 +1,21 @@
+set auto_path [concat [file join [file dirname [info script]] ".."] $auto_path]
+
+package require underscore
+
+set numbers [list]
+for {set i 0} {$i < 100} { incr i } { lappend numbers $i }
+
+puts "mapping using foreach with expression"
+puts [time {
+ set result [list]
+ foreach num $numbers {
+ lappend result [expr { $num * $num }]
+ }
+} 1000]
+
+puts "_::map with expression"
+puts [time {
+ _::map $numbers {{num} {
+ expr { $num * $num }
+ }}
+} 1000]
@@ -0,0 +1 @@
+package ifneeded underscore 0.1 "source $dir/underscore.tcl"
Oops, something went wrong.

0 comments on commit 649b2b6

Please sign in to comment.