AmberRack 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +74 -0
- data/.rvmrc +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +62 -0
- data/README.md +17 -0
- data/Rakefile +24 -0
- data/amber-rack.gemspec +33 -0
- data/app/amber_app.rb +35 -0
- data/app/javascripts/Benchfib.deploy.js +159 -0
- data/app/javascripts/Benchfib.js +159 -0
- data/app/javascripts/Canvas.deploy.js +1464 -0
- data/app/javascripts/Canvas.js +1464 -0
- data/app/javascripts/Compiler.deploy.js +1587 -0
- data/app/javascripts/Compiler.js +1587 -0
- data/app/javascripts/Examples.deploy.js +800 -0
- data/app/javascripts/Examples.js +800 -0
- data/app/javascripts/IDE.deploy.js +3457 -0
- data/app/javascripts/IDE.js +3457 -0
- data/app/javascripts/IDE.js.bak +3420 -0
- data/app/javascripts/JQuery.deploy.js +898 -0
- data/app/javascripts/JQuery.js +898 -0
- data/app/javascripts/Kernel.deploy.js +6761 -0
- data/app/javascripts/Kernel.js +6761 -0
- data/app/javascripts/Parser.deploy.js +1655 -0
- data/app/javascripts/Parser.js +1655 -0
- data/app/javascripts/Raphael-Core.js +0 -0
- data/app/javascripts/Raphael-Graph.js +0 -0
- data/app/javascripts/SUnit.deploy.js +1059 -0
- data/app/javascripts/SUnit.js +1059 -0
- data/app/javascripts/application.js +2 -0
- data/app/javascripts/boot.js +466 -0
- data/app/javascripts/init.js +2 -0
- data/app/javascripts/jquery-1.4.4.min.js +167 -0
- data/app/javascripts/jquery-ui-1.8.9.custom.min.js +781 -0
- data/app/javascripts/jquery.textarea.js +267 -0
- data/app/javascripts/jtalk.js +78 -0
- data/app/javascripts/lib/CodeMirror/LICENSE +19 -0
- data/app/javascripts/lib/CodeMirror/README.md +6 -0
- data/app/javascripts/lib/CodeMirror/compress.html +92 -0
- data/app/javascripts/lib/CodeMirror/css/baboon.png +0 -0
- data/app/javascripts/lib/CodeMirror/css/baboon_vector.svg +153 -0
- data/app/javascripts/lib/CodeMirror/css/docs.css +154 -0
- data/app/javascripts/lib/CodeMirror/demo/activeline.html +72 -0
- data/app/javascripts/lib/CodeMirror/demo/changemode.html +51 -0
- data/app/javascripts/lib/CodeMirror/demo/complete.html +79 -0
- data/app/javascripts/lib/CodeMirror/demo/complete.js +151 -0
- data/app/javascripts/lib/CodeMirror/demo/fullscreen.html +158 -0
- data/app/javascripts/lib/CodeMirror/demo/marker.html +53 -0
- data/app/javascripts/lib/CodeMirror/demo/mustache.html +57 -0
- data/app/javascripts/lib/CodeMirror/demo/preview.html +75 -0
- data/app/javascripts/lib/CodeMirror/demo/resize.html +44 -0
- data/app/javascripts/lib/CodeMirror/demo/runmode.html +50 -0
- data/app/javascripts/lib/CodeMirror/demo/search.html +106 -0
- data/app/javascripts/lib/CodeMirror/demo/theme.html +53 -0
- data/app/javascripts/lib/CodeMirror/index.html +239 -0
- data/app/javascripts/lib/CodeMirror/internals.html +389 -0
- data/app/javascripts/lib/CodeMirror/lib/codemirror.css +67 -0
- data/app/javascripts/lib/CodeMirror/lib/codemirror.js +2144 -0
- data/app/javascripts/lib/CodeMirror/lib/overlay.js +51 -0
- data/app/javascripts/lib/CodeMirror/lib/runmode.js +27 -0
- data/app/javascripts/lib/CodeMirror/manual.html +854 -0
- data/app/javascripts/lib/CodeMirror/mode/clike/clike.js +247 -0
- data/app/javascripts/lib/CodeMirror/mode/clike/index.html +102 -0
- data/app/javascripts/lib/CodeMirror/mode/css/css.js +124 -0
- data/app/javascripts/lib/CodeMirror/mode/css/index.html +56 -0
- data/app/javascripts/lib/CodeMirror/mode/diff/diff.css +3 -0
- data/app/javascripts/lib/CodeMirror/mode/diff/diff.js +13 -0
- data/app/javascripts/lib/CodeMirror/mode/diff/index.html +99 -0
- data/app/javascripts/lib/CodeMirror/mode/haskell/haskell.js +242 -0
- data/app/javascripts/lib/CodeMirror/mode/haskell/index.html +60 -0
- data/app/javascripts/lib/CodeMirror/mode/htmlmixed/htmlmixed.js +79 -0
- data/app/javascripts/lib/CodeMirror/mode/htmlmixed/index.html +52 -0
- data/app/javascripts/lib/CodeMirror/mode/javascript/index.html +78 -0
- data/app/javascripts/lib/CodeMirror/mode/javascript/javascript.js +348 -0
- data/app/javascripts/lib/CodeMirror/mode/lua/index.html +72 -0
- data/app/javascripts/lib/CodeMirror/mode/lua/lua.js +138 -0
- data/app/javascripts/lib/CodeMirror/mode/php/index.html +49 -0
- data/app/javascripts/lib/CodeMirror/mode/php/php.js +110 -0
- data/app/javascripts/lib/CodeMirror/mode/plsql/index.html +63 -0
- data/app/javascripts/lib/CodeMirror/mode/plsql/plsql.js +217 -0
- data/app/javascripts/lib/CodeMirror/mode/python/LICENSE.txt +21 -0
- data/app/javascripts/lib/CodeMirror/mode/python/index.html +123 -0
- data/app/javascripts/lib/CodeMirror/mode/python/python.js +321 -0
- data/app/javascripts/lib/CodeMirror/mode/rst/index.html +526 -0
- data/app/javascripts/lib/CodeMirror/mode/rst/rst.css +75 -0
- data/app/javascripts/lib/CodeMirror/mode/rst/rst.js +333 -0
- data/app/javascripts/lib/CodeMirror/mode/scheme/index.html +65 -0
- data/app/javascripts/lib/CodeMirror/mode/scheme/scheme.js +181 -0
- data/app/javascripts/lib/CodeMirror/mode/smalltalk/index.html +56 -0
- data/app/javascripts/lib/CodeMirror/mode/smalltalk/smalltalk.js +134 -0
- data/app/javascripts/lib/CodeMirror/mode/sparql/index.html +41 -0
- data/app/javascripts/lib/CodeMirror/mode/sparql/sparql.js +143 -0
- data/app/javascripts/lib/CodeMirror/mode/stex/index.html +96 -0
- data/app/javascripts/lib/CodeMirror/mode/stex/stex.js +167 -0
- data/app/javascripts/lib/CodeMirror/mode/xml/index.html +42 -0
- data/app/javascripts/lib/CodeMirror/mode/xml/xml.js +231 -0
- data/app/javascripts/lib/CodeMirror/mode/yaml/index.html +68 -0
- data/app/javascripts/lib/CodeMirror/mode/yaml/yaml.js +95 -0
- data/app/javascripts/lib/CodeMirror/oldrelease.html +178 -0
- data/app/javascripts/lib/CodeMirror/test/index.html +29 -0
- data/app/javascripts/lib/CodeMirror/test/test.js +249 -0
- data/app/javascripts/lib/CodeMirror/theme/default.css +18 -0
- data/app/javascripts/lib/CodeMirror/theme/elegant.css +9 -0
- data/app/javascripts/lib/CodeMirror/theme/jtalk.css +21 -0
- data/app/javascripts/lib/CodeMirror/theme/neat.css +8 -0
- data/app/javascripts/lib/CodeMirror/theme/night.css +20 -0
- data/app/javascripts/lib/jQuery/jquery-1.4.4.min.js +167 -0
- data/app/javascripts/lib/jQuery/jquery-ui-1.8.9.custom.min.js +781 -0
- data/app/javascripts/lib/jQuery/jquery.textarea.js +267 -0
- data/app/smalltalk/Canvas.st +481 -0
- data/app/smalltalk/IDE.st +1752 -0
- data/config.ru +2 -0
- data/lib/amber-rack.rb +4 -0
- data/lib/amber-rack/version.rb +3 -0
- data/public/CodeMirror/LICENSE +19 -0
- data/public/CodeMirror/README.md +6 -0
- data/public/CodeMirror/compress.html +92 -0
- data/public/CodeMirror/css/baboon.png +0 -0
- data/public/CodeMirror/css/baboon_vector.svg +153 -0
- data/public/CodeMirror/css/docs.css +154 -0
- data/public/CodeMirror/demo/activeline.html +72 -0
- data/public/CodeMirror/demo/changemode.html +51 -0
- data/public/CodeMirror/demo/complete.html +79 -0
- data/public/CodeMirror/demo/complete.js +151 -0
- data/public/CodeMirror/demo/fullscreen.html +158 -0
- data/public/CodeMirror/demo/marker.html +53 -0
- data/public/CodeMirror/demo/mustache.html +57 -0
- data/public/CodeMirror/demo/preview.html +75 -0
- data/public/CodeMirror/demo/resize.html +44 -0
- data/public/CodeMirror/demo/runmode.html +50 -0
- data/public/CodeMirror/demo/search.html +106 -0
- data/public/CodeMirror/demo/theme.html +53 -0
- data/public/CodeMirror/index.html +239 -0
- data/public/CodeMirror/internals.html +389 -0
- data/public/CodeMirror/lib/codemirror.css +67 -0
- data/public/CodeMirror/lib/codemirror.js +2144 -0
- data/public/CodeMirror/lib/overlay.js +51 -0
- data/public/CodeMirror/lib/runmode.js +27 -0
- data/public/CodeMirror/manual.html +854 -0
- data/public/CodeMirror/mode/clike/clike.js +247 -0
- data/public/CodeMirror/mode/clike/index.html +102 -0
- data/public/CodeMirror/mode/css/css.js +124 -0
- data/public/CodeMirror/mode/css/index.html +56 -0
- data/public/CodeMirror/mode/diff/diff.css +3 -0
- data/public/CodeMirror/mode/diff/diff.js +13 -0
- data/public/CodeMirror/mode/diff/index.html +99 -0
- data/public/CodeMirror/mode/haskell/haskell.js +242 -0
- data/public/CodeMirror/mode/haskell/index.html +60 -0
- data/public/CodeMirror/mode/htmlmixed/htmlmixed.js +79 -0
- data/public/CodeMirror/mode/htmlmixed/index.html +52 -0
- data/public/CodeMirror/mode/javascript/index.html +78 -0
- data/public/CodeMirror/mode/javascript/javascript.js +348 -0
- data/public/CodeMirror/mode/lua/index.html +72 -0
- data/public/CodeMirror/mode/lua/lua.js +138 -0
- data/public/CodeMirror/mode/php/index.html +49 -0
- data/public/CodeMirror/mode/php/php.js +110 -0
- data/public/CodeMirror/mode/plsql/index.html +63 -0
- data/public/CodeMirror/mode/plsql/plsql.js +217 -0
- data/public/CodeMirror/mode/python/LICENSE.txt +21 -0
- data/public/CodeMirror/mode/python/index.html +123 -0
- data/public/CodeMirror/mode/python/python.js +321 -0
- data/public/CodeMirror/mode/rst/index.html +526 -0
- data/public/CodeMirror/mode/rst/rst.css +75 -0
- data/public/CodeMirror/mode/rst/rst.js +333 -0
- data/public/CodeMirror/mode/scheme/index.html +65 -0
- data/public/CodeMirror/mode/scheme/scheme.js +181 -0
- data/public/CodeMirror/mode/smalltalk/index.html +56 -0
- data/public/CodeMirror/mode/smalltalk/smalltalk.js +134 -0
- data/public/CodeMirror/mode/sparql/index.html +41 -0
- data/public/CodeMirror/mode/sparql/sparql.js +143 -0
- data/public/CodeMirror/mode/stex/index.html +96 -0
- data/public/CodeMirror/mode/stex/stex.js +167 -0
- data/public/CodeMirror/mode/xml/index.html +42 -0
- data/public/CodeMirror/mode/xml/xml.js +231 -0
- data/public/CodeMirror/mode/yaml/index.html +68 -0
- data/public/CodeMirror/mode/yaml/yaml.js +95 -0
- data/public/CodeMirror/oldrelease.html +178 -0
- data/public/CodeMirror/test/index.html +29 -0
- data/public/CodeMirror/test/test.js +249 -0
- data/public/CodeMirror/theme/default.css +18 -0
- data/public/CodeMirror/theme/elegant.css +9 -0
- data/public/CodeMirror/theme/jtalk.css +21 -0
- data/public/CodeMirror/theme/neat.css +8 -0
- data/public/CodeMirror/theme/night.css +20 -0
- data/public/css/jtalk.css +362 -0
- data/public/css/style.css +456 -0
- data/public/css/sunit.css +66 -0
- data/public/ide/fork_me.png +0 -0
- data/public/ide/screen2.png +0 -0
- data/public/ide/style.css +456 -0
- data/public/ide/syntax.css +61 -0
- data/public/ide/text_header.png +0 -0
- data/public/ide/title_container1.png +0 -0
- data/public/images/background_box.png +0 -0
- data/public/images/background_header.png +0 -0
- data/public/images/balloon_header.png +0 -0
- data/views/index.haml +66 -0
- metadata +341 -0
data/.gitignore
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
#----------------------------------------------------------------------------
|
2
|
+
# Ignore these files when commiting to a git repository
|
3
|
+
#
|
4
|
+
# The original version of this file is found here:
|
5
|
+
# https://github.com/RailsApps/rails3-application-templates/raw/master/files/gitignore.txt
|
6
|
+
#
|
7
|
+
# Corrections? Improvements? Create a GitHub issue:
|
8
|
+
# http://github.com/RailsApps/rails3-application-templates/issues
|
9
|
+
#----------------------------------------------------------------------------
|
10
|
+
|
11
|
+
# bundler state
|
12
|
+
/.bundle
|
13
|
+
/vendor/bundle/
|
14
|
+
|
15
|
+
# minimal Rails specific artifacts
|
16
|
+
db/*.sqlite3
|
17
|
+
/log/*
|
18
|
+
tmp/*
|
19
|
+
pkg
|
20
|
+
|
21
|
+
# various artifacts
|
22
|
+
/couchdb.std*
|
23
|
+
**.war
|
24
|
+
*.rbc
|
25
|
+
*.sassc
|
26
|
+
.rspec
|
27
|
+
.redcar/
|
28
|
+
.sass-cache
|
29
|
+
/config/config.yml
|
30
|
+
/config/Vagrantfile
|
31
|
+
/config/couchdb.yml
|
32
|
+
/config/database.yml
|
33
|
+
/coverage.data
|
34
|
+
/coverage/
|
35
|
+
/db/*.javadb/
|
36
|
+
/db/*.sqlite3-journal
|
37
|
+
/doc/api/
|
38
|
+
/doc/app/
|
39
|
+
/doc/features.html
|
40
|
+
/doc/specs.html
|
41
|
+
/public/cache
|
42
|
+
/public/stylesheets/compiled
|
43
|
+
/public/system
|
44
|
+
/public/uploads
|
45
|
+
/spec/tmp/*
|
46
|
+
/cache
|
47
|
+
/capybara*
|
48
|
+
/capybara-*.html
|
49
|
+
/gems
|
50
|
+
/rerun.txt
|
51
|
+
/spec/requests
|
52
|
+
/spec/routing
|
53
|
+
/spec/views
|
54
|
+
/spec/javascripts/generated/*
|
55
|
+
/specifications
|
56
|
+
|
57
|
+
# scm revert files
|
58
|
+
**.orig
|
59
|
+
|
60
|
+
# Mac finder artifacts
|
61
|
+
.DS_Store
|
62
|
+
|
63
|
+
# Netbeans project directory
|
64
|
+
/nbproject/
|
65
|
+
|
66
|
+
# Textmate project files
|
67
|
+
/*.tmpproj
|
68
|
+
|
69
|
+
# vim artifacts
|
70
|
+
**.swp
|
71
|
+
#
|
72
|
+
# Vagrant artifacts
|
73
|
+
/.vagrant
|
74
|
+
/package.box
|
data/.rvmrc
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
AmberRack (0.1.0)
|
5
|
+
builder
|
6
|
+
coffee-filter
|
7
|
+
haml
|
8
|
+
rack-sprockets
|
9
|
+
rack_dav
|
10
|
+
sinatra
|
11
|
+
sprockets
|
12
|
+
|
13
|
+
GEM
|
14
|
+
remote: http://rubygems.org/
|
15
|
+
specs:
|
16
|
+
archive-tar-minitar (0.5.2)
|
17
|
+
builder (3.0.0)
|
18
|
+
coffee-filter (0.1.1)
|
19
|
+
coffee-script (>= 2.2.0)
|
20
|
+
haml (>= 3.0.18)
|
21
|
+
coffee-script (2.2.0)
|
22
|
+
coffee-script-source
|
23
|
+
execjs
|
24
|
+
coffee-script-source (1.1.2)
|
25
|
+
columnize (0.3.4)
|
26
|
+
execjs (1.2.9)
|
27
|
+
multi_json (~> 1.0)
|
28
|
+
haml (3.1.3)
|
29
|
+
linecache19 (0.5.12)
|
30
|
+
ruby_core_source (>= 0.1.4)
|
31
|
+
multi_json (1.0.3)
|
32
|
+
rack (1.3.4)
|
33
|
+
rack-protection (1.1.4)
|
34
|
+
rack
|
35
|
+
rack-sprockets (1.1.0)
|
36
|
+
rack (~> 1.0)
|
37
|
+
sprockets (~> 1.0)
|
38
|
+
rack_dav (0.1.3)
|
39
|
+
ruby-debug-base19 (0.11.25)
|
40
|
+
columnize (>= 0.3.1)
|
41
|
+
linecache19 (>= 0.5.11)
|
42
|
+
ruby_core_source (>= 0.1.4)
|
43
|
+
ruby-debug19 (0.11.6)
|
44
|
+
columnize (>= 0.3.1)
|
45
|
+
linecache19 (>= 0.5.11)
|
46
|
+
ruby-debug-base19 (>= 0.11.19)
|
47
|
+
ruby_core_source (0.1.5)
|
48
|
+
archive-tar-minitar (>= 0.5.2)
|
49
|
+
sinatra (1.3.1)
|
50
|
+
rack (~> 1.3, >= 1.3.4)
|
51
|
+
rack-protection (~> 1.1, >= 1.1.2)
|
52
|
+
tilt (~> 1.3, >= 1.3.3)
|
53
|
+
sprockets (1.0.2)
|
54
|
+
tilt (1.3.3)
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
AmberRack!
|
61
|
+
linecache19
|
62
|
+
ruby-debug19
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Amber-Rack
|
2
|
+
|
3
|
+
This is a Rack app that serves [Amber](http://amber-project.org/) and
|
4
|
+
saves code via [RackDAV](https://github.com/georgi/rack_dav).
|
5
|
+
|
6
|
+
|
7
|
+
## Setup and Usage
|
8
|
+
|
9
|
+
First, install all the needed gems:
|
10
|
+
|
11
|
+
rake setup
|
12
|
+
|
13
|
+
Then, start up the server:
|
14
|
+
|
15
|
+
rake server
|
16
|
+
|
17
|
+
Now open http://localhost:9292 in a browser.
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
bundler_installed = !!(%x[gem list] =~ /bundler/)
|
4
|
+
|
5
|
+
if bundler_installed
|
6
|
+
require 'bundler'
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
|
9
|
+
task :default => :server
|
10
|
+
|
11
|
+
desc "Start the Rack server"
|
12
|
+
task :server do
|
13
|
+
sh 'bundle exec rackup'
|
14
|
+
end
|
15
|
+
else
|
16
|
+
task :default => :setup
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Setup the local environment"
|
20
|
+
task :setup do
|
21
|
+
sh 'gem install bundler --no-ri --no-rdoc' unless bundler_installed
|
22
|
+
sh 'bundle install'
|
23
|
+
puts "Done!\n\n"
|
24
|
+
end
|
data/amber-rack.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "amber-rack/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "AmberRack"
|
7
|
+
s.version = AmberRack::VERSION
|
8
|
+
s.authors = ["JohnnyT"]
|
9
|
+
s.email = ["johnnyt@xan.do"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Smalltalk brought to the web}
|
12
|
+
s.description = s.summary
|
13
|
+
|
14
|
+
s.rubyforge_project = "amber-rack"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency "sinatra"
|
22
|
+
s.add_dependency "rack_dav"
|
23
|
+
s.add_dependency "builder"
|
24
|
+
s.add_dependency "sprockets"
|
25
|
+
s.add_dependency "rack-sprockets"
|
26
|
+
s.add_dependency "coffee-filter"
|
27
|
+
s.add_dependency "haml"
|
28
|
+
|
29
|
+
s.add_development_dependency "linecache19"
|
30
|
+
s.add_development_dependency "ruby-debug19"
|
31
|
+
# specify any dependencies here; for example:
|
32
|
+
# s.add_runtime_dependency "rest-client"
|
33
|
+
end
|
data/app/amber_app.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.setup
|
4
|
+
require 'haml'
|
5
|
+
require 'sinatra/base'
|
6
|
+
require 'rack_dav'
|
7
|
+
|
8
|
+
RACK_ROOT = File.expand_path('..', File.dirname(__FILE__))
|
9
|
+
|
10
|
+
class AmberWebApp < Sinatra::Base
|
11
|
+
set :root, RACK_ROOT
|
12
|
+
|
13
|
+
# use Rack::Sprockets, :root => RACK_ROOT
|
14
|
+
|
15
|
+
get '/' do
|
16
|
+
haml :index
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
AmberApp = Rack::Builder.new do
|
21
|
+
use Rack::ShowExceptions
|
22
|
+
use Rack::CommonLogger
|
23
|
+
|
24
|
+
map '/js' do
|
25
|
+
run RackDAV::Handler.new(:root => File.expand_path('app/javascripts', RACK_ROOT))
|
26
|
+
end
|
27
|
+
|
28
|
+
map '/st' do
|
29
|
+
run RackDAV::Handler.new(:root => File.expand_path('app/smalltalk', RACK_ROOT))
|
30
|
+
end
|
31
|
+
|
32
|
+
map '/' do
|
33
|
+
run AmberWebApp
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
smalltalk.addClass('Benchfib', smalltalk.Object, [], 'Benchfib');
|
2
|
+
|
3
|
+
smalltalk.addMethod(
|
4
|
+
'_main',
|
5
|
+
smalltalk.method({
|
6
|
+
selector: 'main',
|
7
|
+
category: 'not yet classified',
|
8
|
+
fn: function (){
|
9
|
+
var self=this;
|
10
|
+
var result=nil;
|
11
|
+
result=smalltalk.send((0), "_tinyBenchmarks", []);
|
12
|
+
smalltalk.send(console, "_log_", [smalltalk.send(unescape("0%20tinyBenchmarks%20%3D%3E%20"), "__plus", [result])]);
|
13
|
+
return self;},
|
14
|
+
source: unescape('main%0A%0A%09%7C%20result%20%7C%0A%09result%20%3A%3D%200%20tinyBenchmarks.%0A%09console%20log%3A%20%270%20tinyBenchmarks%20%3D%3E%20%27%20+%20result'),
|
15
|
+
messageSends: ["tinyBenchmarks", "log:", unescape("+")],
|
16
|
+
referencedClasses: []
|
17
|
+
}),
|
18
|
+
smalltalk.Benchfib.klass);
|
19
|
+
|
20
|
+
|
21
|
+
smalltalk.addMethod(
|
22
|
+
'_benchFib',
|
23
|
+
smalltalk.method({
|
24
|
+
selector: 'benchFib',
|
25
|
+
category: '*Benchfib',
|
26
|
+
fn: function (){
|
27
|
+
var self=this;
|
28
|
+
return smalltalk.send(smalltalk.send(self, "__lt", [(2)]), "_ifTrue_ifFalse_", [(function(){return (1);}), (function(){return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "__minus", [(1)]), "_benchFib", []), "__plus", [smalltalk.send(smalltalk.send(self, "__minus", [(2)]), "_benchFib", [])]), "__plus", [(1)]);})]);
|
29
|
+
return self;},
|
30
|
+
source: unescape('benchFib%0A%09%22Handy%20send-heavy%20benchmark%22%0A%09%22%28result%20//%20seconds%20to%20run%29%20%3D%20approx%20calls%20per%20second%22%0A%09%22%20%7C%20r%20t%20%7C%0A%09%20%20t%20%3A%3D%20Time%20millisecondsToRun%3A%20%5Br%20%3A%3D%2026%20benchFib%5D.%0A%09%20%20%28r%20*%201000%29%20//%20t%22%0A%09%22138000%20on%20a%20Mac%208100/100%22%0A%09%5E%20self%20%3C%202%0A%09%09ifTrue%3A%20%5B1%5D%20%0A%09%09ifFalse%3A%20%5B%28self-1%29%20benchFib%20+%20%28self-2%29%20benchFib%20+%201%5D'),
|
31
|
+
messageSends: ["ifTrue:ifFalse:", unescape("%3C"), unescape("+"), "benchFib", unescape("-")],
|
32
|
+
referencedClasses: []
|
33
|
+
}),
|
34
|
+
smalltalk.Number);
|
35
|
+
|
36
|
+
smalltalk.addMethod(
|
37
|
+
'_benchmark',
|
38
|
+
smalltalk.method({
|
39
|
+
selector: 'benchmark',
|
40
|
+
category: '*Benchfib',
|
41
|
+
fn: function (){
|
42
|
+
var self=this;
|
43
|
+
var size=nil;
|
44
|
+
var flags=nil;
|
45
|
+
var prime=nil;
|
46
|
+
var k=nil;
|
47
|
+
var count=nil;
|
48
|
+
size=(8190);
|
49
|
+
smalltalk.send((1), "_to_do_", [self, (function(iter){count=(0);flags=smalltalk.send(smalltalk.Array, "_new", []);smalltalk.send(size, "_timesRepeat_", [(function(){return smalltalk.send(flags, "_add_", [true]);})]);return smalltalk.send((1), "_to_do_", [size, (function(i){return smalltalk.send(smalltalk.send(flags, "_at_", [i]), "_ifTrue_", [(function(){prime=smalltalk.send(i, "__plus", [(1)]);k=smalltalk.send(i, "__plus", [prime]);smalltalk.send((function(){return smalltalk.send(k, "__lt_eq", [size]);}), "_whileTrue_", [(function(){smalltalk.send(flags, "_at_put_", [k, false]);return k=smalltalk.send(k, "__plus", [prime]);})]);return count=smalltalk.send(count, "__plus", [(1)]);})]);})]);})]);
|
50
|
+
return count;
|
51
|
+
return self;},
|
52
|
+
source: unescape('benchmark%20%20%22Handy%20bytecode-heavy%20benchmark%22%0A%09%22%28500000%20//%20time%20to%20run%29%20%3D%20approx%20bytecodes%20per%20second%22%0A%09%225000000%20//%20%28Time%20millisecondsToRun%3A%20%5B10%20benchmark%5D%29%20*%201000%22%0A%09%223059000%20on%20a%20Mac%208100/100%22%0A%20%20%20%20%7C%20size%20flags%20prime%20k%20count%20%7C%0A%20%20%20%20size%20%3A%3D%208190.%0A%20%20%20%201%20to%3A%20self%20do%3A%0A%20%20%20%20%20%20%20%20%5B%3Aiter%20%7C%0A%20%20%20%20%20%20%20%20count%20%3A%3D%200.%0A%20%20%20%20%20%20%20%20flags%20%3A%3D%20Array%20new.%0A%20%20%20%20%20%20%20%20size%20timesRepeat%3A%20%5B%20flags%20add%3A%20true%5D.%0A%20%20%20%20%20%20%20%201%20to%3A%20size%20do%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%5B%3Ai%20%7C%20%28flags%20at%3A%20i%29%20ifTrue%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5Bprime%20%3A%3D%20i+1.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20k%20%3A%3D%20i%20+%20prime.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5Bk%20%3C%3D%20size%5D%20whileTrue%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5Bflags%20at%3A%20k%20put%3A%20false.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20k%20%3A%3D%20k%20+%20prime%5D.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20count%20%3A%3D%20count%20+%201%5D%5D%5D.%0A%20%20%20%20%5E%20count'),
|
53
|
+
messageSends: ["to:do:", "new", "timesRepeat:", "add:", "ifTrue:", "at:", unescape("+"), "whileTrue:", unescape("%3C%3D"), "at:put:"],
|
54
|
+
referencedClasses: [smalltalk.Array]
|
55
|
+
}),
|
56
|
+
smalltalk.Number);
|
57
|
+
|
58
|
+
smalltalk.addMethod(
|
59
|
+
'_tinyBenchmarks',
|
60
|
+
smalltalk.method({
|
61
|
+
selector: 'tinyBenchmarks',
|
62
|
+
category: '*Benchfib',
|
63
|
+
fn: function (){
|
64
|
+
var self=this;
|
65
|
+
var t1=nil;
|
66
|
+
var t2=nil;
|
67
|
+
var r=nil;
|
68
|
+
var n1=nil;
|
69
|
+
var n2=nil;
|
70
|
+
n1=(1);
|
71
|
+
smalltalk.send((function(){t1=smalltalk.send(smalltalk.Date, "_millisecondsToRun_", [(function(){return smalltalk.send(n1, "_benchmark", []);})]);return smalltalk.send(t1, "__lt", [(1000)]);}), "_whileTrue_", [(function(){return n1=smalltalk.send(n1, "__star", [(2)]);})]);
|
72
|
+
n2=(28);
|
73
|
+
smalltalk.send((function(){t2=smalltalk.send(smalltalk.Date, "_millisecondsToRun_", [(function(){return r=smalltalk.send(n2, "_benchFib", []);})]);return smalltalk.send(t2, "__lt", [(1000)]);}), "_whileTrue_", [(function(){return n2=smalltalk.send(n2, "__plus", [(1)]);})]);
|
74
|
+
return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(n1, "__star", [(500000)]), "__star", [(1000)]), "__slash", [t1]), "_printString", []), "__comma", [unescape("%20bytecodes/sec%3B%20")]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(r, "__star", [(1000)]), "__slash", [t2]), "_printString", [])]), "__comma", [unescape("%20sends/sec")]);
|
75
|
+
return self;},
|
76
|
+
source: unescape('tinyBenchmarks%0A%09%22Report%20the%20results%20of%20running%20the%20two%20tiny%20Squeak%20benchmarks.%0A%09ar%209/10/1999%3A%20Adjusted%20to%20run%20at%20least%201%20sec%20to%20get%20more%20stable%20results%22%0A%09%220%20tinyBenchmarks%22%0A%09%22On%20a%20292%20MHz%20G3%20Mac%3A%2022727272%20bytecodes/sec%3B%20984169%20sends/sec%22%0A%09%22On%20a%20400%20MHz%20PII/Win98%3A%20%2018028169%20bytecodes/sec%3B%201081272%20sends/sec%22%0A%09%7C%20t1%20t2%20r%20n1%20n2%20%7C%0A%09n1%20%3A%3D%201.%0A%09%5Bt1%20%3A%3D%20Date%20millisecondsToRun%3A%20%5Bn1%20benchmark%5D.%0A%09t1%20%3C%201000%5D%20whileTrue%3A%5Bn1%20%3A%3D%20n1%20*%202%5D.%20%22Note%3A%20%23benchmark%27s%20runtime%20is%20about%20O%28n%29%22%0A%0A%09n2%20%3A%3D%2028.%0A%09%5Bt2%20%3A%3D%20Date%20millisecondsToRun%3A%20%5Br%20%3A%3D%20n2%20benchFib%5D.%0A%09t2%20%3C%201000%5D%20whileTrue%3A%5Bn2%20%3A%3D%20n2%20+%201%5D.%20%0A%09%22Note%3A%20%23benchFib%27s%20runtime%20is%20about%20O%28k%5En%29%2C%0A%09%09where%20k%20is%20the%20golden%20number%20%3D%20%281%20+%205%20sqrt%29%20/%202%20%3D%201.618....%22%0A%0A%09%5E%20%28%28n1%20*%20500000%20*%201000%29%20/%20t1%29%20printString%2C%20%27%20bytecodes/sec%3B%20%27%2C%0A%09%20%20%28%28r%20*%201000%29%20/%20t2%29%20printString%2C%20%27%20sends/sec%27'),
|
77
|
+
messageSends: ["whileTrue:", "millisecondsToRun:", "benchmark", unescape("%3C"), unescape("*"), "benchFib", unescape("+"), unescape("%2C"), "printString", unescape("/")],
|
78
|
+
referencedClasses: [smalltalk.Date]
|
79
|
+
}),
|
80
|
+
smalltalk.Number);
|
81
|
+
|
82
|
+
smalltalk.addMethod(
|
83
|
+
'_jsbenchFib',
|
84
|
+
smalltalk.method({
|
85
|
+
selector: 'jsbenchFib',
|
86
|
+
category: '*Benchfib',
|
87
|
+
fn: function (){
|
88
|
+
var self=this;
|
89
|
+
if (this < 2) {
|
90
|
+
return 1;
|
91
|
+
} else {
|
92
|
+
return (this-1)._jsbenchFib() + (this-2)._jsbenchFib() + 1;};
|
93
|
+
return self;},
|
94
|
+
source: unescape('jsbenchFib%0A%20%0A%09%3Cif%20%28this%20%3C%202%29%20%7B%0Areturn%201%3B%0A%7D%20else%20%7B%0Areturn%20%28this-1%29._jsbenchFib%28%29%20+%20%28this-2%29._jsbenchFib%28%29%20+%201%3B%7D%3E'),
|
95
|
+
messageSends: [],
|
96
|
+
referencedClasses: []
|
97
|
+
}),
|
98
|
+
smalltalk.Number);
|
99
|
+
|
100
|
+
smalltalk.addMethod(
|
101
|
+
'_jsbenchmark',
|
102
|
+
smalltalk.method({
|
103
|
+
selector: 'jsbenchmark',
|
104
|
+
category: '*Benchfib',
|
105
|
+
fn: function (){
|
106
|
+
var self=this;
|
107
|
+
|
108
|
+
var size = 8190;
|
109
|
+
var count;
|
110
|
+
for (var z=0;z<this;z++) {
|
111
|
+
count = 0;
|
112
|
+
var flags = new Array();
|
113
|
+
for (var p=0; p<size; p++) {
|
114
|
+
flags[p] = true;
|
115
|
+
}
|
116
|
+
for (var i=1;i<=size;i++) {
|
117
|
+
if (flags[i-1]) {
|
118
|
+
var prime = i+1;
|
119
|
+
var k = i + prime;
|
120
|
+
while (k <= size) {
|
121
|
+
flags[k-1] = false;
|
122
|
+
k = k + prime;
|
123
|
+
}
|
124
|
+
count = count + 1;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
return count;
|
129
|
+
return self;},
|
130
|
+
source: unescape('jsbenchmark%0A%0A%3C%0Avar%20size%20%3D%208190%3B%0Avar%20count%3B%0Afor%20%28var%20z%3D0%3Bz%3Cthis%3Bz++%29%20%7B%0A%20%20count%20%3D%200%3B%0A%20%20var%20flags%20%3D%20new%20Array%28%29%3B%0A%20%20for%20%28var%20p%3D0%3B%20p%3Csize%3B%20p++%29%20%7B%0A%20%20%20%20flags%5Bp%5D%20%3D%20true%3B%0A%20%20%7D%0A%20%20for%20%28var%20i%3D1%3Bi%3C%3Dsize%3Bi++%29%20%7B%0A%20%20%20%20if%20%28flags%5Bi-1%5D%29%20%7B%0A%20%20%20%20%20%20var%20prime%20%3D%20i+1%3B%0A%20%20%20%20%20%20var%20k%20%3D%20i%20+%20prime%3B%0A%20%20%20%20%20%20while%20%28k%20%3C%3D%20size%29%20%7B%0A%20%20%20%20%20%20%20%20flags%5Bk-1%5D%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20k%20%3D%20k%20+%20prime%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20count%20%3D%20count%20+%201%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0Areturn%20count%3E'),
|
131
|
+
messageSends: [],
|
132
|
+
referencedClasses: []
|
133
|
+
}),
|
134
|
+
smalltalk.Number);
|
135
|
+
|
136
|
+
smalltalk.addMethod(
|
137
|
+
'_jstinyBenchmarks',
|
138
|
+
smalltalk.method({
|
139
|
+
selector: 'jstinyBenchmarks',
|
140
|
+
category: '*Benchfib',
|
141
|
+
fn: function (){
|
142
|
+
var self=this;
|
143
|
+
var t1=nil;
|
144
|
+
var t2=nil;
|
145
|
+
var r=nil;
|
146
|
+
var n1=nil;
|
147
|
+
var n2=nil;
|
148
|
+
n1=(1);
|
149
|
+
smalltalk.send((function(){t1=smalltalk.send(smalltalk.Date, "_millisecondsToRun_", [(function(){return smalltalk.send(n1, "_jsbenchmark", []);})]);return smalltalk.send(t1, "__lt", [(1000)]);}), "_whileTrue_", [(function(){return n1=smalltalk.send(n1, "__star", [(2)]);})]);
|
150
|
+
n2=(28);
|
151
|
+
smalltalk.send((function(){t2=smalltalk.send(smalltalk.Date, "_millisecondsToRun_", [(function(){return r=smalltalk.send(n2, "_jsbenchFib", []);})]);return smalltalk.send(t2, "__lt", [(1000)]);}), "_whileTrue_", [(function(){return n2=smalltalk.send(n2, "__plus", [(1)]);})]);
|
152
|
+
return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(n1, "__star", [(500000)]), "__star", [(1000)]), "__slash", [t1]), "_printString", []), "__comma", [unescape("%20bytecodes/sec%3B%20")]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(r, "__star", [(1000)]), "__slash", [t2]), "_printString", [])]), "__comma", [unescape("%20sends/sec")]);
|
153
|
+
return self;},
|
154
|
+
source: unescape('jstinyBenchmarks%0A%09%220%20jstinyBenchmarks%22%0A%0A%09%7C%20t1%20t2%20r%20n1%20n2%20%7C%0A%09n1%20%3A%3D%201.%0A%09%5Bt1%20%3A%3D%20Date%20millisecondsToRun%3A%20%5Bn1%20jsbenchmark%5D.%0A%09t1%20%3C%201000%5D%20whileTrue%3A%5Bn1%20%3A%3D%20n1%20*%202%5D.%20%22Note%3A%20%23benchmark%27s%20runtime%20is%20about%20O%28n%29%22%0A%0A%09n2%20%3A%3D%2028.%0A%09%5Bt2%20%3A%3D%20Date%20millisecondsToRun%3A%20%5Br%20%3A%3D%20n2%20jsbenchFib%5D.%0A%09t2%20%3C%201000%5D%20whileTrue%3A%5Bn2%20%3A%3D%20n2%20+%201%5D.%20%0A%09%22Note%3A%20%23jsbenchFib%27s%20runtime%20is%20about%20O%28k%5En%29%2C%0A%09%09where%20k%20is%20the%20golden%20number%20%3D%20%281%20+%205%20sqrt%29%20/%202%20%3D%201.618....%22%0A%0A%09%5E%20%28%28n1%20*%20500000%20*%201000%29%20/%20t1%29%20printString%2C%20%27%20bytecodes/sec%3B%20%27%2C%0A%09%20%20%28%28r%20*%201000%29%20/%20t2%29%20printString%2C%20%27%20sends/sec%27'),
|
155
|
+
messageSends: ["whileTrue:", "millisecondsToRun:", "jsbenchmark", unescape("%3C"), unescape("*"), "jsbenchFib", unescape("+"), unescape("%2C"), "printString", unescape("/")],
|
156
|
+
referencedClasses: [smalltalk.Date]
|
157
|
+
}),
|
158
|
+
smalltalk.Number);
|
159
|
+
|
@@ -0,0 +1,159 @@
|
|
1
|
+
smalltalk.addClass('Benchfib', smalltalk.Object, [], 'Benchfib');
|
2
|
+
|
3
|
+
smalltalk.addMethod(
|
4
|
+
'_main',
|
5
|
+
smalltalk.method({
|
6
|
+
selector: 'main',
|
7
|
+
category: 'not yet classified',
|
8
|
+
fn: function (){
|
9
|
+
var self=this;
|
10
|
+
var result=nil;
|
11
|
+
result=smalltalk.send((0), "_tinyBenchmarks", []);
|
12
|
+
smalltalk.send(console, "_log_", [smalltalk.send(unescape("0%20tinyBenchmarks%20%3D%3E%20"), "__plus", [result])]);
|
13
|
+
return self;},
|
14
|
+
source: unescape('main%0A%0A%09%7C%20result%20%7C%0A%09result%20%3A%3D%200%20tinyBenchmarks.%0A%09console%20log%3A%20%270%20tinyBenchmarks%20%3D%3E%20%27%20+%20result'),
|
15
|
+
messageSends: ["tinyBenchmarks", "log:", unescape("+")],
|
16
|
+
referencedClasses: []
|
17
|
+
}),
|
18
|
+
smalltalk.Benchfib.klass);
|
19
|
+
|
20
|
+
|
21
|
+
smalltalk.addMethod(
|
22
|
+
'_benchFib',
|
23
|
+
smalltalk.method({
|
24
|
+
selector: 'benchFib',
|
25
|
+
category: '*Benchfib',
|
26
|
+
fn: function (){
|
27
|
+
var self=this;
|
28
|
+
return smalltalk.send(smalltalk.send(self, "__lt", [(2)]), "_ifTrue_ifFalse_", [(function(){return (1);}), (function(){return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "__minus", [(1)]), "_benchFib", []), "__plus", [smalltalk.send(smalltalk.send(self, "__minus", [(2)]), "_benchFib", [])]), "__plus", [(1)]);})]);
|
29
|
+
return self;},
|
30
|
+
source: unescape('benchFib%0A%09%22Handy%20send-heavy%20benchmark%22%0A%09%22%28result%20//%20seconds%20to%20run%29%20%3D%20approx%20calls%20per%20second%22%0A%09%22%20%7C%20r%20t%20%7C%0A%09%20%20t%20%3A%3D%20Time%20millisecondsToRun%3A%20%5Br%20%3A%3D%2026%20benchFib%5D.%0A%09%20%20%28r%20*%201000%29%20//%20t%22%0A%09%22138000%20on%20a%20Mac%208100/100%22%0A%09%5E%20self%20%3C%202%0A%09%09ifTrue%3A%20%5B1%5D%20%0A%09%09ifFalse%3A%20%5B%28self-1%29%20benchFib%20+%20%28self-2%29%20benchFib%20+%201%5D'),
|
31
|
+
messageSends: ["ifTrue:ifFalse:", unescape("%3C"), unescape("+"), "benchFib", unescape("-")],
|
32
|
+
referencedClasses: []
|
33
|
+
}),
|
34
|
+
smalltalk.Number);
|
35
|
+
|
36
|
+
smalltalk.addMethod(
|
37
|
+
'_benchmark',
|
38
|
+
smalltalk.method({
|
39
|
+
selector: 'benchmark',
|
40
|
+
category: '*Benchfib',
|
41
|
+
fn: function (){
|
42
|
+
var self=this;
|
43
|
+
var size=nil;
|
44
|
+
var flags=nil;
|
45
|
+
var prime=nil;
|
46
|
+
var k=nil;
|
47
|
+
var count=nil;
|
48
|
+
size=(8190);
|
49
|
+
smalltalk.send((1), "_to_do_", [self, (function(iter){count=(0);flags=smalltalk.send(smalltalk.Array, "_new", []);smalltalk.send(size, "_timesRepeat_", [(function(){return smalltalk.send(flags, "_add_", [true]);})]);return smalltalk.send((1), "_to_do_", [size, (function(i){return smalltalk.send(smalltalk.send(flags, "_at_", [i]), "_ifTrue_", [(function(){prime=smalltalk.send(i, "__plus", [(1)]);k=smalltalk.send(i, "__plus", [prime]);smalltalk.send((function(){return smalltalk.send(k, "__lt_eq", [size]);}), "_whileTrue_", [(function(){smalltalk.send(flags, "_at_put_", [k, false]);return k=smalltalk.send(k, "__plus", [prime]);})]);return count=smalltalk.send(count, "__plus", [(1)]);})]);})]);})]);
|
50
|
+
return count;
|
51
|
+
return self;},
|
52
|
+
source: unescape('benchmark%20%20%22Handy%20bytecode-heavy%20benchmark%22%0A%09%22%28500000%20//%20time%20to%20run%29%20%3D%20approx%20bytecodes%20per%20second%22%0A%09%225000000%20//%20%28Time%20millisecondsToRun%3A%20%5B10%20benchmark%5D%29%20*%201000%22%0A%09%223059000%20on%20a%20Mac%208100/100%22%0A%20%20%20%20%7C%20size%20flags%20prime%20k%20count%20%7C%0A%20%20%20%20size%20%3A%3D%208190.%0A%20%20%20%201%20to%3A%20self%20do%3A%0A%20%20%20%20%20%20%20%20%5B%3Aiter%20%7C%0A%20%20%20%20%20%20%20%20count%20%3A%3D%200.%0A%20%20%20%20%20%20%20%20flags%20%3A%3D%20Array%20new.%0A%20%20%20%20%20%20%20%20size%20timesRepeat%3A%20%5B%20flags%20add%3A%20true%5D.%0A%20%20%20%20%20%20%20%201%20to%3A%20size%20do%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%5B%3Ai%20%7C%20%28flags%20at%3A%20i%29%20ifTrue%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5Bprime%20%3A%3D%20i+1.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20k%20%3A%3D%20i%20+%20prime.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5Bk%20%3C%3D%20size%5D%20whileTrue%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5Bflags%20at%3A%20k%20put%3A%20false.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20k%20%3A%3D%20k%20+%20prime%5D.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20count%20%3A%3D%20count%20+%201%5D%5D%5D.%0A%20%20%20%20%5E%20count'),
|
53
|
+
messageSends: ["to:do:", "new", "timesRepeat:", "add:", "ifTrue:", "at:", unescape("+"), "whileTrue:", unescape("%3C%3D"), "at:put:"],
|
54
|
+
referencedClasses: [smalltalk.Array]
|
55
|
+
}),
|
56
|
+
smalltalk.Number);
|
57
|
+
|
58
|
+
smalltalk.addMethod(
|
59
|
+
'_tinyBenchmarks',
|
60
|
+
smalltalk.method({
|
61
|
+
selector: 'tinyBenchmarks',
|
62
|
+
category: '*Benchfib',
|
63
|
+
fn: function (){
|
64
|
+
var self=this;
|
65
|
+
var t1=nil;
|
66
|
+
var t2=nil;
|
67
|
+
var r=nil;
|
68
|
+
var n1=nil;
|
69
|
+
var n2=nil;
|
70
|
+
n1=(1);
|
71
|
+
smalltalk.send((function(){t1=smalltalk.send(smalltalk.Date, "_millisecondsToRun_", [(function(){return smalltalk.send(n1, "_benchmark", []);})]);return smalltalk.send(t1, "__lt", [(1000)]);}), "_whileTrue_", [(function(){return n1=smalltalk.send(n1, "__star", [(2)]);})]);
|
72
|
+
n2=(28);
|
73
|
+
smalltalk.send((function(){t2=smalltalk.send(smalltalk.Date, "_millisecondsToRun_", [(function(){return r=smalltalk.send(n2, "_benchFib", []);})]);return smalltalk.send(t2, "__lt", [(1000)]);}), "_whileTrue_", [(function(){return n2=smalltalk.send(n2, "__plus", [(1)]);})]);
|
74
|
+
return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(n1, "__star", [(500000)]), "__star", [(1000)]), "__slash", [t1]), "_printString", []), "__comma", [unescape("%20bytecodes/sec%3B%20")]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(r, "__star", [(1000)]), "__slash", [t2]), "_printString", [])]), "__comma", [unescape("%20sends/sec")]);
|
75
|
+
return self;},
|
76
|
+
source: unescape('tinyBenchmarks%0A%09%22Report%20the%20results%20of%20running%20the%20two%20tiny%20Squeak%20benchmarks.%0A%09ar%209/10/1999%3A%20Adjusted%20to%20run%20at%20least%201%20sec%20to%20get%20more%20stable%20results%22%0A%09%220%20tinyBenchmarks%22%0A%09%22On%20a%20292%20MHz%20G3%20Mac%3A%2022727272%20bytecodes/sec%3B%20984169%20sends/sec%22%0A%09%22On%20a%20400%20MHz%20PII/Win98%3A%20%2018028169%20bytecodes/sec%3B%201081272%20sends/sec%22%0A%09%7C%20t1%20t2%20r%20n1%20n2%20%7C%0A%09n1%20%3A%3D%201.%0A%09%5Bt1%20%3A%3D%20Date%20millisecondsToRun%3A%20%5Bn1%20benchmark%5D.%0A%09t1%20%3C%201000%5D%20whileTrue%3A%5Bn1%20%3A%3D%20n1%20*%202%5D.%20%22Note%3A%20%23benchmark%27s%20runtime%20is%20about%20O%28n%29%22%0A%0A%09n2%20%3A%3D%2028.%0A%09%5Bt2%20%3A%3D%20Date%20millisecondsToRun%3A%20%5Br%20%3A%3D%20n2%20benchFib%5D.%0A%09t2%20%3C%201000%5D%20whileTrue%3A%5Bn2%20%3A%3D%20n2%20+%201%5D.%20%0A%09%22Note%3A%20%23benchFib%27s%20runtime%20is%20about%20O%28k%5En%29%2C%0A%09%09where%20k%20is%20the%20golden%20number%20%3D%20%281%20+%205%20sqrt%29%20/%202%20%3D%201.618....%22%0A%0A%09%5E%20%28%28n1%20*%20500000%20*%201000%29%20/%20t1%29%20printString%2C%20%27%20bytecodes/sec%3B%20%27%2C%0A%09%20%20%28%28r%20*%201000%29%20/%20t2%29%20printString%2C%20%27%20sends/sec%27'),
|
77
|
+
messageSends: ["whileTrue:", "millisecondsToRun:", "benchmark", unescape("%3C"), unescape("*"), "benchFib", unescape("+"), unescape("%2C"), "printString", unescape("/")],
|
78
|
+
referencedClasses: [smalltalk.Date]
|
79
|
+
}),
|
80
|
+
smalltalk.Number);
|
81
|
+
|
82
|
+
smalltalk.addMethod(
|
83
|
+
'_jsbenchFib',
|
84
|
+
smalltalk.method({
|
85
|
+
selector: 'jsbenchFib',
|
86
|
+
category: '*Benchfib',
|
87
|
+
fn: function (){
|
88
|
+
var self=this;
|
89
|
+
if (this < 2) {
|
90
|
+
return 1;
|
91
|
+
} else {
|
92
|
+
return (this-1)._jsbenchFib() + (this-2)._jsbenchFib() + 1;};
|
93
|
+
return self;},
|
94
|
+
source: unescape('jsbenchFib%0A%20%0A%09%3Cif%20%28this%20%3C%202%29%20%7B%0Areturn%201%3B%0A%7D%20else%20%7B%0Areturn%20%28this-1%29._jsbenchFib%28%29%20+%20%28this-2%29._jsbenchFib%28%29%20+%201%3B%7D%3E'),
|
95
|
+
messageSends: [],
|
96
|
+
referencedClasses: []
|
97
|
+
}),
|
98
|
+
smalltalk.Number);
|
99
|
+
|
100
|
+
smalltalk.addMethod(
|
101
|
+
'_jsbenchmark',
|
102
|
+
smalltalk.method({
|
103
|
+
selector: 'jsbenchmark',
|
104
|
+
category: '*Benchfib',
|
105
|
+
fn: function (){
|
106
|
+
var self=this;
|
107
|
+
|
108
|
+
var size = 8190;
|
109
|
+
var count;
|
110
|
+
for (var z=0;z<this;z++) {
|
111
|
+
count = 0;
|
112
|
+
var flags = new Array();
|
113
|
+
for (var p=0; p<size; p++) {
|
114
|
+
flags[p] = true;
|
115
|
+
}
|
116
|
+
for (var i=1;i<=size;i++) {
|
117
|
+
if (flags[i-1]) {
|
118
|
+
var prime = i+1;
|
119
|
+
var k = i + prime;
|
120
|
+
while (k <= size) {
|
121
|
+
flags[k-1] = false;
|
122
|
+
k = k + prime;
|
123
|
+
}
|
124
|
+
count = count + 1;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
return count;
|
129
|
+
return self;},
|
130
|
+
source: unescape('jsbenchmark%0A%0A%3C%0Avar%20size%20%3D%208190%3B%0Avar%20count%3B%0Afor%20%28var%20z%3D0%3Bz%3Cthis%3Bz++%29%20%7B%0A%20%20count%20%3D%200%3B%0A%20%20var%20flags%20%3D%20new%20Array%28%29%3B%0A%20%20for%20%28var%20p%3D0%3B%20p%3Csize%3B%20p++%29%20%7B%0A%20%20%20%20flags%5Bp%5D%20%3D%20true%3B%0A%20%20%7D%0A%20%20for%20%28var%20i%3D1%3Bi%3C%3Dsize%3Bi++%29%20%7B%0A%20%20%20%20if%20%28flags%5Bi-1%5D%29%20%7B%0A%20%20%20%20%20%20var%20prime%20%3D%20i+1%3B%0A%20%20%20%20%20%20var%20k%20%3D%20i%20+%20prime%3B%0A%20%20%20%20%20%20while%20%28k%20%3C%3D%20size%29%20%7B%0A%20%20%20%20%20%20%20%20flags%5Bk-1%5D%20%3D%20false%3B%0A%20%20%20%20%20%20%20%20k%20%3D%20k%20+%20prime%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20count%20%3D%20count%20+%201%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0Areturn%20count%3E'),
|
131
|
+
messageSends: [],
|
132
|
+
referencedClasses: []
|
133
|
+
}),
|
134
|
+
smalltalk.Number);
|
135
|
+
|
136
|
+
smalltalk.addMethod(
|
137
|
+
'_jstinyBenchmarks',
|
138
|
+
smalltalk.method({
|
139
|
+
selector: 'jstinyBenchmarks',
|
140
|
+
category: '*Benchfib',
|
141
|
+
fn: function (){
|
142
|
+
var self=this;
|
143
|
+
var t1=nil;
|
144
|
+
var t2=nil;
|
145
|
+
var r=nil;
|
146
|
+
var n1=nil;
|
147
|
+
var n2=nil;
|
148
|
+
n1=(1);
|
149
|
+
smalltalk.send((function(){t1=smalltalk.send(smalltalk.Date, "_millisecondsToRun_", [(function(){return smalltalk.send(n1, "_jsbenchmark", []);})]);return smalltalk.send(t1, "__lt", [(1000)]);}), "_whileTrue_", [(function(){return n1=smalltalk.send(n1, "__star", [(2)]);})]);
|
150
|
+
n2=(28);
|
151
|
+
smalltalk.send((function(){t2=smalltalk.send(smalltalk.Date, "_millisecondsToRun_", [(function(){return r=smalltalk.send(n2, "_jsbenchFib", []);})]);return smalltalk.send(t2, "__lt", [(1000)]);}), "_whileTrue_", [(function(){return n2=smalltalk.send(n2, "__plus", [(1)]);})]);
|
152
|
+
return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(n1, "__star", [(500000)]), "__star", [(1000)]), "__slash", [t1]), "_printString", []), "__comma", [unescape("%20bytecodes/sec%3B%20")]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(r, "__star", [(1000)]), "__slash", [t2]), "_printString", [])]), "__comma", [unescape("%20sends/sec")]);
|
153
|
+
return self;},
|
154
|
+
source: unescape('jstinyBenchmarks%0A%09%220%20jstinyBenchmarks%22%0A%0A%09%7C%20t1%20t2%20r%20n1%20n2%20%7C%0A%09n1%20%3A%3D%201.%0A%09%5Bt1%20%3A%3D%20Date%20millisecondsToRun%3A%20%5Bn1%20jsbenchmark%5D.%0A%09t1%20%3C%201000%5D%20whileTrue%3A%5Bn1%20%3A%3D%20n1%20*%202%5D.%20%22Note%3A%20%23benchmark%27s%20runtime%20is%20about%20O%28n%29%22%0A%0A%09n2%20%3A%3D%2028.%0A%09%5Bt2%20%3A%3D%20Date%20millisecondsToRun%3A%20%5Br%20%3A%3D%20n2%20jsbenchFib%5D.%0A%09t2%20%3C%201000%5D%20whileTrue%3A%5Bn2%20%3A%3D%20n2%20+%201%5D.%20%0A%09%22Note%3A%20%23jsbenchFib%27s%20runtime%20is%20about%20O%28k%5En%29%2C%0A%09%09where%20k%20is%20the%20golden%20number%20%3D%20%281%20+%205%20sqrt%29%20/%202%20%3D%201.618....%22%0A%0A%09%5E%20%28%28n1%20*%20500000%20*%201000%29%20/%20t1%29%20printString%2C%20%27%20bytecodes/sec%3B%20%27%2C%0A%09%20%20%28%28r%20*%201000%29%20/%20t2%29%20printString%2C%20%27%20sends/sec%27'),
|
155
|
+
messageSends: ["whileTrue:", "millisecondsToRun:", "jsbenchmark", unescape("%3C"), unescape("*"), "jsbenchFib", unescape("+"), unescape("%2C"), "printString", unescape("/")],
|
156
|
+
referencedClasses: [smalltalk.Date]
|
157
|
+
}),
|
158
|
+
smalltalk.Number);
|
159
|
+
|