aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez>2005-03-04 08:03:43 +0000
committerantirez <antirez>2005-03-04 08:03:43 +0000
commita16c964a08a76b94ab1b3c961acec59f4cb06da6 (patch)
treec446574feb7dc2161fb0ecc35e8c25ad4fe79f35
parentb19ba0f0f7a994306878b348f223a8d3d2995d1b (diff)
downloadjimtcl-a16c964a08a76b94ab1b3c961acec59f4cb06da6.zip
jimtcl-a16c964a08a76b94ab1b3c961acec59f4cb06da6.tar.gz
jimtcl-a16c964a08a76b94ab1b3c961acec59f4cb06da6.tar.bz2
more benchmarks. Initial size of hashtables modified.
Some documentation change.
-rw-r--r--AUTHORS2
-rw-r--r--README32
-rw-r--r--TODO2
-rw-r--r--bench.tcl59
-rw-r--r--jim.h2
5 files changed, 91 insertions, 6 deletions
diff --git a/AUTHORS b/AUTHORS
index 55ae1f0..8a7817b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,6 +1,6 @@
Salvatore Sanfilippo <antirez@invece.org>
-with the help (patches, bug reports, ideas) of:
+with the help (patches, bug reports, ideas, extensions) of:
Pat Thoyts
Clemens Hintze
diff --git a/README b/README
index 7e46dd6..32d9f75 100644
--- a/README
+++ b/README
@@ -21,7 +21,7 @@ dual ported objects to ensure that the execution time does not reflect
the semantic of the language :)
------------------------------------------------------------------------------
-WHERE JIM IS USEFUL?
+WHEN JIM CAN BE USEFUL?
------------------------------------------------------------------------------
1) If you are writing an application, and want to make it scriptable, with
@@ -30,6 +30,11 @@ with a big system. You can just put jim.c and jim.h files in your project
and use the Jim API to write the glue code that makes your application
scriptable in Jim, with the following advantages:
+- Jim is not the next "little language", but it's a Tcl implementation.
+ You can reuse your knowledge if you already Tcl skills, or enjoy
+ the availability of documentation, books, web resources, ...
+ (for example check my online Tcl book at http://www.invece.org/tclwise)
+
- Jim is simple, 10k lines of code. If you want to adapt it you can hack
the source code to feet the needs of your application. It makes you
able to have scripting for default, and avoid external dependences.
@@ -79,6 +84,31 @@ scriptable in Jim, with the following advantages:
implementation ;).
--------------------------------------------------------------------------------
+HOW BIG IS IT?
+--------------------------------------------------------------------------------
+
+Jim compiled with -Os is 65k currently. Still it lacks core commands
+that will make it a little bigger, but not too much... only what's
+strictly required will end inside the core, the rest will be implemented
+as extensions.
+
+Note that the actual Jim core is much smaller, if you strip away commands.
+If you can do without [expr] (that's big about code size), and some
+other command you may probably end with a 40k executable.
+
+--------------------------------------------------------------------------------
+HOW FAST IS IT?
+--------------------------------------------------------------------------------
+
+Jim is in most code faster than Tcl7.6p2 (latest 7.x version),
+and slower than Tcl 8.4.x. You can expect pretty decent performances
+for such a little interpreter.
+
+If you want a more precise measure, there is 'bench.tcl' inside this
+distribution that will run both under Jim and Tcl, so just execute
+it with both the interpreters and see what you get :)
+
+--------------------------------------------------------------------------------
HOW TO COMPILE
--------------------------------------------------------------------------------
diff --git a/TODO b/TODO
index 478a2bc..905cc4f 100644
--- a/TODO
+++ b/TODO
@@ -28,6 +28,8 @@ EXTENSIONS
SPEED OPTIMIZATIONS
- Cache call frames instead to free/realloc they at every proc call.
+ (partially done, now there is to cache the variables has table
+ contained in the call frames).
IMPLEMENTATION ISSUES
diff --git a/bench.tcl b/bench.tcl
index 796ad02..cde6fec 100644
--- a/bench.tcl
+++ b/bench.tcl
@@ -36,10 +36,11 @@ set last 42
proc make_gen_random {} {
global IM IA IC
- set body "
+ set params [list IM $IM IA $IA IC $IC]
+ set body [string map $params {
global last
- expr {(\$max * \[set last \[expr {(\$last * $IA + $IC) % $IM}\]\]) / $IM}
- "
+ expr {($max * [set last [expr {($last * IA + IC) % IM}]]) / IM}
+ }]
proc gen_random {max} $body
}
@@ -203,6 +204,56 @@ proc dyncode_list {} {
}
}
+### PI DIGITS ##################################################################
+
+proc pi_digits {} {
+ set N 300
+ set LEN [expr {10*$N/3}]
+ set result ""
+
+ set a [string repeat " 2" $LEN]
+ set nines 0
+ set predigit 0
+ set nines {}
+
+ set i0 [expr {$LEN+1}]
+ set quot0 [expr {2*$LEN+1}]
+ for {set j 0} {$j<$N} {incr j} {
+ set q 0
+ set i $i0
+ set quot $quot0
+ set pos -1
+ foreach apos $a {
+ set x [expr {10*$apos + $q * [incr i -1]}]
+ lset a [incr pos] [expr {$x % [incr quot -2]}]
+ set q [expr {$x / $quot}]
+ }
+ lset a end [expr {$q % 10}]
+ set q [expr {$q / 10}]
+ if {$q < 8} {
+ append result $predigit $nines
+ set nines {}
+ set predigit $q
+ } elseif {$q == 9} {
+ append nines 9
+ } else {
+ append result [expr {$predigit+1}][string map {9 0} $nines]
+ set nines {}
+ set predigit 0
+ }
+ }
+ #puts $result$predigit
+}
+
+### EXPAND #####################################################################
+
+proc expand {} {
+ for {set i 0} {$i < 100000} {incr i} {
+ set a [list a b c d e f]
+ lappend b {expand}$a
+ }
+}
+
### RUN ALL ####################################################################
bench {busy loop} {x}
@@ -216,3 +267,5 @@ bench {nested loops} {nestedloops}
bench {rotate} {rotate 100000}
bench {dynamic code} {dyncode}
bench {dynamic code (list)} {dyncode_list}
+bench {PI digits} {pi_digits}
+bench {expand} {expand}
diff --git a/jim.h b/jim.h
index 200bd55..ab9541c 100644
--- a/jim.h
+++ b/jim.h
@@ -157,7 +157,7 @@ typedef struct Jim_HashTableIterator {
} Jim_HashTableIterator;
/* This is the initial size of every hash table */
-#define JIM_HT_INITIAL_SIZE 256
+#define JIM_HT_INITIAL_SIZE 32
/* ------------------------------- Macros ------------------------------------*/
#define Jim_FreeEntryVal(ht, entry) \