ZenHacks 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,47 @@
1
+
2
+ $TESTING = true
3
+ require 'test/unit' unless defined? $ZENTEST and $ZENTEST
4
+ require 'parse_tree_graph'
5
+
6
+ class TestSexpGrapher < Test::Unit::TestCase
7
+
8
+ def setup
9
+ @grapher = SexpGrapher.new
10
+ @count = 0
11
+ end
12
+
13
+ def util_process_snippet(code)
14
+ @count += 1
15
+ klassname = "SGExample#{@count}"
16
+ klass = "class #{klassname}; def example; #{code}; end; end"
17
+ Object.class_eval klass
18
+ klass = Object.const_get klassname
19
+ result = ParseTree.new.parse_tree(klass)
20
+ result = result[0][3][2][1][2..-1] # just the body of the method
21
+ result = Sexp.from_array(result)
22
+ grapher = SexpGrapher.new
23
+ grapher.process(result)
24
+ grapher.graphstr
25
+ end
26
+
27
+ def test_graph_basic
28
+ expected = 'digraph a_graph
29
+ {
30
+ node [ shape = box, style = filled ];
31
+ "n0001" [ label = ":call" ]
32
+ "n0002" [ label = ":lit" ]
33
+ "n0003" [ label = "1" ]
34
+ "n0004" [ label = ":+" ]
35
+ "n0005" [ label = ":array" ]
36
+ "n0006" [ label = ":lit" ]
37
+ "n0007" [ label = "1" ]
38
+ "n0001" -> "n0002";
39
+ "n0001" -> "n0004";
40
+ "n0001" -> "n0005";
41
+ "n0002" -> "n0003";
42
+ "n0005" -> "n0006";
43
+ "n0006" -> "n0007";
44
+ }'
45
+ assert_equal expected, util_process_snippet("1+1")
46
+ end
47
+ end
@@ -0,0 +1,86 @@
1
+ #!/bin/bash
2
+
3
+ VERSION='1.0.0' # this is mainly to appease my relese script's requirements.
4
+
5
+ export GEM_SKIP=RubyInline
6
+
7
+ # rm -rf ~/.ruby_inline
8
+
9
+ type=$1
10
+ if [ -z "$1" ]; then
11
+ type=help
12
+ fi
13
+
14
+ N=10000
15
+ if [ ! -z "$2" ]; then
16
+ N=$2
17
+ fi
18
+
19
+ if [ $type = "help" ]; then
20
+ echo "usage: $0 type"
21
+ echo " type ="
22
+ echo " native - run factorial with native ruby"
23
+ echo " debug - run factorial with ruby debugger"
24
+ echo " zendebug - run factorial with zendebugger"
25
+ echo " profile - ..."
26
+ echo " bench - ..."
27
+ echo " native-rex - ..."
28
+ echo " zendebug-rex - ..."
29
+ echo " debug-rex - ..."
30
+ echo " bench-rex - ..."
31
+ fi
32
+
33
+ RI=../../RubyInline/dev
34
+
35
+ if [ $type = "native" ]; then
36
+ yes c | time -p ruby -I$RI misc/factorial.rb $N
37
+ fi
38
+
39
+ if [ $type = "debug" ]; then
40
+ yes c | time -p ruby -rdebug -I$RI misc/factorial.rb $N
41
+ fi
42
+
43
+ if [ $type = "zendebug" ]; then
44
+ yes c | time -p ruby -rzendebug -Ilib:$RI misc/factorial.rb $N
45
+ fi
46
+
47
+ if [ $type = "profile" ]; then
48
+ yes c | time -p ruby -rprofile -rzendebug -Ilib:$RI misc/factorial.rb 500
49
+ fi
50
+
51
+ if [ $type = "bench" ]; then
52
+ echo "N=$N"
53
+ for type in native zendebug debug; do
54
+ echo -n "$type: "
55
+ for M in 1 2 3 4 5; do
56
+ ./zendebug-demo.sh $type $N 2>&1 | ruby -nae 'puts $F[1] if /real/'
57
+ done | add -m
58
+ done
59
+ fi
60
+
61
+ ############################################################
62
+
63
+ if [ $N = "10000" ]; then
64
+ N=2
65
+ fi
66
+
67
+ if [ $type = "native-rex" ]; then
68
+ # (cd rexml_3.1.1/benchmarks/; yes c | ruby -I../../$RI comparison.rb $N)
69
+ (cd rexml_3.1.1/benchmarks/; yes c | ruby -I..:../../$RI bench.rb $N)
70
+ fi
71
+
72
+ if [ $type = "zendebug-rex" ]; then
73
+ (cd rexml_3.1.1/benchmarks/; yes c | ruby -I../../$RI:../../lib -rzendebug comparison.rb $N)
74
+ fi
75
+
76
+ if [ $type = "debug-rex" ]; then
77
+ (cd rexml_3.1.1/benchmarks/; yes c | ruby -I../../$RI -rdebug comparison.rb $N)
78
+ fi
79
+
80
+ if [ $type = "bench-rex" ]; then
81
+ for type in native-rex zendebug-rex debug-rex; do
82
+ echo "$type:"
83
+ ./zendebug-demo.sh $type $N
84
+ echo
85
+ done
86
+ fi
@@ -0,0 +1,22 @@
1
+ #!/bin/bash
2
+
3
+ N=$1
4
+
5
+ if [ -z $N ]; then N=500000; fi
6
+ if [ -z $2 ]; then SKIP=no; else SKIP=yes; fi
7
+
8
+ # rm -rf ~/.ruby_inline
9
+ # sync; sync; sync
10
+ export GEM_SKIP=ParseTree:RubyInline
11
+
12
+ echo running $N iterations of factorial demo:
13
+ echo
14
+
15
+ if [ $SKIP = no ]; then
16
+ echo "ruby: (time ruby factorial.rb $N)"
17
+ time ruby misc/factorial.rb $N
18
+ echo
19
+ fi
20
+
21
+ echo "zenspider: (time ruby -rzenoptimize factorial.rb $N)"
22
+ time ruby -I.:lib:../../ParseTree/dev/lib:../../RubyInline/dev:../../ruby_to_c/dev -rzenoptimize misc/factorial.rb $N
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+
3
+ N=$1
4
+
5
+ if [ -z $N ]; then N=5000; fi
6
+ if [ -z $2 ]; then SKIP=no; else SKIP=yes; fi
7
+
8
+ rm -rf ~/.ruby_inline
9
+ sync; sync; sync
10
+
11
+ echo N=$N
12
+
13
+ if [ $SKIP = no ]; then
14
+ echo
15
+ echo ruby vanilla:
16
+ time ruby misc/factorial.rb $N
17
+
18
+ echo
19
+ echo ruby profiler:
20
+ time ruby -rprofile misc/factorial.rb $N
21
+ fi
22
+
23
+ echo
24
+ echo zenspider profiler:
25
+ export GEM_SKIP=RubyInline
26
+ time ruby -I.:lib:../../RubyInline/dev -rzenprofile misc/factorial.rb $N
27
+
28
+ # shugo's version
29
+ # time ruby -I.:lib -runprof misc/factorial.rb $N 2>&1 | head
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.10.1
3
+ specification_version: 1
4
+ name: ZenHacks
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.0.0
7
+ date: 2005-06-12
8
+ summary: "Tools and toys of mine that don't have a better home."
9
+ require_paths:
10
+ - lib
11
+ email: ryand-ruby@zenspider.com
12
+ homepage: http://rubyforge.org/projects/zenhacks/
13
+ rubyforge_project: zenhacks
14
+ description: "** INCLUDES"
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ -
22
+ - ">"
23
+ - !ruby/object:Gem::Version
24
+ version: 0.0.0
25
+ version:
26
+ platform: ruby
27
+ authors:
28
+ - Ryan Davis
29
+ files:
30
+ - History.txt
31
+ - Manifest.txt
32
+ - README.txt
33
+ - bin/macgraph
34
+ - bin/parse_tree_graph
35
+ - bin/test_stats
36
+ - fixloops-demo.sh
37
+ - lib/OrderedHash.rb
38
+ - lib/class-path.rb
39
+ - lib/discover.rb
40
+ - lib/fixloops.rb
41
+ - lib/graph.rb
42
+ - lib/muffdaddy.rb
43
+ - lib/r2c_hacks.rb
44
+ - lib/ruby2ruby.rb
45
+ - lib/timezones.rb
46
+ - lib/zendebug.rb
47
+ - lib/zenoptimize.rb
48
+ - lib/zenprofile.rb
49
+ - misc/factorial.rb
50
+ - misc/find_c_methods
51
+ - misc/fixloops-bad.rb
52
+ - r2c_hacks-demo.rb
53
+ - test/TestOrderedHash.rb
54
+ - test/r2ctestcase.rb
55
+ - test/test_parse_tree_graph.rb
56
+ - zendebug-demo.sh
57
+ - zenoptimize-demo.sh
58
+ - zenprofile-demo.sh
59
+ test_files: []
60
+ rdoc_options: []
61
+ extra_rdoc_files: []
62
+ executables:
63
+ - macgraph
64
+ - parse_tree_graph
65
+ - test_stats
66
+ extensions: []
67
+ requirements:
68
+ - Many. Depends on what you want to play with.
69
+ dependencies: []