Skip to content

Commit 1405461

Browse files
author
r-lyeh
committed
gml
1 parent 9119af5 commit 1405461

33 files changed

+6999
-123
lines changed

README.md

+44-41
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ scriptorium
44
- quick and dirty benchmark suite (dont take it too serious)
55
- benchmarked latest versions at the time of writing (Jul 2015)
66

7-
### languages/implementations evaluated (33)
7+
### languages/implementations evaluated (34)
88
- angelscript
99
- angelscript (angelscript-jit)
1010
- c (c4)
@@ -13,6 +13,7 @@ scriptorium
1313
- chaiscript
1414
- dao
1515
- gamemonkey
16+
- gml
1617
- javascript (42tiny-js)
1718
- javascript (duktape)
1819
- jtc
@@ -39,57 +40,59 @@ scriptorium
3940
- tcl (picol)
4041
- wren
4142

43+
### rank
44+
|Language|Time|Relative Lua speed|Score|
45+
|:-------|---:|:----------------:|----:|
46+
|[c/vc](https://www.visualstudio.com/)|0.0741186 s.|![100%](http://progressed.io/bar/100?title=x18)|1808 pt|
47+
|[lua/luajit](https://github.com/LuaDist/luajit)|0.111428 s.|![100%](http://progressed.io/bar/100?title=x12)|1203 pt|
48+
|[c/libtcc](http://bellard.org/tcc/)|0.151179 s.|![100%](http://progressed.io/bar/100?title=x08)|886 pt|
49+
|[pawn/asm](http://www.compuphase.com/pawn/pawn.htm)|0.38402 s.|![100%](http://progressed.io/bar/100?title=x03)|349 pt|
50+
|[pawn](http://www.compuphase.com/pawn/pawn.htm)|0.719387 s.|![100%](http://progressed.io/bar/100)|186 pt|
51+
|[neko/nekovm](https://github.com/HaxeFoundation/neko)|1.10385 s.|![100%](http://progressed.io/bar/100)|121 pt|
52+
|[lua](https://github.com/LuaDist/lua)|1.34052 s.|![100%](http://progressed.io/bar/100)|100 pt|
53+
|[ruby/tinyrb(ist)](https://github.com/sanchapereira/tinyrb-ist)|1.44126 s.|![93.0103%](http://progressed.io/bar/93)|93 pt|
54+
|[gamemonkey](http://www.gmscript.com/)|1.69064 s.|![79.2907%](http://progressed.io/bar/79)|79 pt|
55+
|[as/angelscript-jit](https://github.com/BlindMindStudios/AngelScript-JIT-Compiler)|1.85891 s.|![72.1132%](http://progressed.io/bar/72)|72 pt|
56+
|[wren](https://github.com/munificent/wren)|1.99672 s.|![67.1361%](http://progressed.io/bar/67)|67 pt|
57+
|[lily](https://github.com/jesserayadkins/lily)|2.00502 s.|![66.8582%](http://progressed.io/bar/66)|66 pt|
58+
|[as/angelscript](http://www.angelcode.com/angelscript/)|2.03945 s.|![65.7295%](http://progressed.io/bar/65)|65 pt|
59+
|[ruby/mruby](https://github.com/mruby/mruby)|2.09807 s.|![63.893%](http://progressed.io/bar/63)|63 pt|
60+
|[squirrel](http://squirrel-lang.org/)|2.12571 s.|![63.0622%](http://progressed.io/bar/63)|63 pt|
61+
|[c/c4](https://github.com/rswier/c4)|2.53838 s.|![52.8101%](http://progressed.io/bar/52)|52 pt|
62+
|[python/micropython](https://github.com/micropython/micropython)|2.84204 s.|![47.1675%](http://progressed.io/bar/47)|47 pt|
63+
|[dao](https://github.com/daokoder/dao)|2.87563 s.|![46.6166%](http://progressed.io/bar/46)|46 pt|
64+
|[quakec/gmqcc](https://github.com/graphitemaster/gmqcc)|3.06013 s.|![43.806%](http://progressed.io/bar/43)|43 pt|
65+
|[objectscript](https://github.com/unitpoint/objectscript)|3.10825 s.|![43.1278%](http://progressed.io/bar/43)|43 pt|
66+
|[lisp/minilisp](https://github.com/rui314/minilisp)|6.95091 s.|![19.2855%](http://progressed.io/bar/19)|19 pt|
67+
|[js/duktape](https://github.com/svaarala/duktape)|9.54355 s.|![14.0463%](http://progressed.io/bar/14)|14 pt|
68+
|[gml](https://github.com/graphitemaster/gml)|16.4427 s.|![8.15268%](http://progressed.io/bar/8)|8 pt|
69+
|[psl](https://github.com/Silica/PSL)|17.6445 s.|![7.59738%](http://progressed.io/bar/7)|7 pt|
70+
|[python/tinypy(panda)](https://github.com/dkasak/tinypy-panda)|21.7993 s.|![6.14937%](http://progressed.io/bar/6)|6 pt|
71+
|[scheme/s9](http://www.t3x.org/s9fes/)|33.1601 s.|![4.04257%](http://progressed.io/bar/4)|4 pt|
72+
|[jx9](http://jx9.symisc.net/)|43.5976 s.|![3.07476%](http://progressed.io/bar/3)|3 pt|
73+
|[jtc](https://github.com/progschj/jtc)|47.021 s.|![2.8509%](http://progressed.io/bar/2)|2 pt|
74+
|[scheme/tinyscheme](http://tinyscheme.sourceforge.net/home.html)|65.398 s.|![2.04979%](http://progressed.io/bar/2)|2 pt|
75+
|[lisp/paren](https://bitbucket.org/ktg/paren)|72.9008 s.|![1.83883%](http://progressed.io/bar/1)|1 pt|
76+
|[lisp/lispy90](http://howtowriteaprogram.blogspot.com.es/2010/11/lisp-interpreter-in-90-lines-of-c.html)|91.7667 s.|![1.46079%](http://progressed.io/bar/1)|1 pt|
77+
|[tcl/picol](http://wiki.tcl.tk/17893)|151.527 s.|![0.884674%](http://progressed.io/bar/0)|0 pt|
78+
|[chaiscript](https://github.com/ChaiScript/ChaiScript)|175.038 s.|![0.765845%](http://progressed.io/bar/0)|0 pt|
79+
|[js/42tiny-js](https://github.com/ardi69/42tiny-js)|227.17 s.|![0.590096%](http://progressed.io/bar/0)|0 pt|
80+
81+
- AMD A10 3.8 GHz, 8 GiB, Windows 7 64bit.
82+
- Compiled on VS2015 RC if possible, VS2013 elsewhere.
83+
4284
### language requirements
4385
- must embed from C++.
4486
- must compile on vs2015 (or vs2013 at least).
4587
- must link statically.
4688
- must not require (heavy) makefiles/cygwin/build-systems to build.
89+
- must be self-contained (no LLVM).
4790
- must use jit/optimizations if available.
4891
- must compare fair to other languages. for example:
4992
- must not use yield/coroutines on recursive fibonacci test.
5093
- must disable threading if possible (not all languages are thread-safe)
5194
- etc
5295

53-
### results
54-
|Language|Time|Relative Lua speed|Score|
55-
|:-------|---:|:----------------:|----:|
56-
|c/vc|0.0655255 s.|![100%](http://progressed.io/bar/100)|2323 pt|
57-
|lua/luajit-2.0/src/luajit|0.0906679 s.|![100%](http://progressed.io/bar/100)|1679 pt|
58-
|c/tcc-0.9.26/win32/tcc|0.127398 s.|![100%](http://progressed.io/bar/100)|1195 pt|
59-
|pawn/pawn-asm|0.460578 s.|![100%](http://progressed.io/bar/100)|330 pt|
60-
|pawn/pawn|0.858627 s.|![100%](http://progressed.io/bar/100)|177 pt|
61-
|neko/neko|1.3005 s.|![100%](http://progressed.io/bar/100)|117 pt|
62-
|lua|1.52243 s.|![100%](http://progressed.io/bar/100)|100 pt|
63-
|tinyrb|1.55396 s.|![97.971%](http://progressed.io/bar/97)|97 pt|
64-
|gamemonkey/bin/gme64|1.71352 s.|![88.8481%](http://progressed.io/bar/88)|88 pt|
65-
|angelscript/as|1.96192 s.|![77.599%](http://progressed.io/bar/77)|77 pt|
66-
|angelscript/asjit|2.00607 s.|![75.8912%](http://progressed.io/bar/75)|75 pt|
67-
|lily/lily|2.03696 s.|![74.7403%](http://progressed.io/bar/74)|74 pt|
68-
|wren/wren|2.24041 s.|![67.9532%](http://progressed.io/bar/67)|67 pt|
69-
|ruby/mruby|2.40104 s.|![63.4071%](http://progressed.io/bar/63)|63 pt|
70-
|c/c4/c4|2.88247 s.|![52.8169%](http://progressed.io/bar/52)|52 pt|
71-
|dao/dao|2.90203 s.|![52.4609%](http://progressed.io/bar/52)|52 pt|
72-
|squirrel/sq3|3.1019 s.|![49.0806%](http://progressed.io/bar/49)|49 pt|
73-
|quakec/gmqcc/qcvm|3.44478 s.|![44.1953%](http://progressed.io/bar/44)|44 pt|
74-
|python/mpython|3.564 s.|![42.7169%](http://progressed.io/bar/42)|42 pt|
75-
|os/os|3.7224 s.|![40.8992%](http://progressed.io/bar/40)|40 pt|
76-
|lisp/minilisp/minilisp|7.4961 s.|![20.3096%](http://progressed.io/bar/20)|20 pt|
77-
|javascript/duktape/duktape|9.21308 s.|![16.5247%](http://progressed.io/bar/16)|16 pt|
78-
|psl/psl|19.4708 s.|![7.81904%](http://progressed.io/bar/7)|7 pt|
79-
|python/tinypy-panda/build/tinypy|22.3401 s.|![6.81479%](http://progressed.io/bar/6)|6 pt|
80-
|s9|36.9632 s.|![4.11877%](http://progressed.io/bar/4)|4 pt|
81-
|jx9/jx9|41.3571 s.|![3.68118%](http://progressed.io/bar/3)|3 pt|
82-
|jtc/jtc|49.5935 s.|![3.06982%](http://progressed.io/bar/3)|3 pt|
83-
|scheme|72.6125 s.|![2.09665%](http://progressed.io/bar/2)|2 pt|
84-
|paren-1.9.6|78.547 s.|![1.93824%](http://progressed.io/bar/1)|1 pt|
85-
|lisp/lispy90/lispy90|101.345 s.|![1.50223%](http://progressed.io/bar/1)|1 pt|
86-
|tcl/picol/picol|163.352 s.|![0.931993%](http://progressed.io/bar/0)|0 pt|
87-
|chaiscript/chai|185.719 s.|![0.819749%](http://progressed.io/bar/0)|0 pt|
88-
|javascript/42tiny-js/42tinyjs|232.703 s.|![0.654237%](http://progressed.io/bar/0)|0 pt|
89-
90-
- AMD A10 3.8 GHz, 8 GiB, Windows 7 64bit.
91-
- Compiled on VS2015 RC if possible, VS2013 elsewhere.
92-
9396
### to add (soon)
9497
- @todo {
9598
- add exe size

bench.cc

+66-41
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct timing {
3434
#include <string>
3535
#include <fstream>
3636
#include <set>
37+
#include <map>
3738
#include <vector>
3839
#include <sstream>
3940

@@ -58,37 +59,43 @@ std::string base( const std::string &app = std::string() ) {
5859
}
5960

6061
int main( int argc, const char **argv ) {
62+
int ret = 0;
6163

62-
if( argc <= 2 ) {
63-
return 0;
64-
}
65-
66-
int N = std::strtoul( argv[1], NULL, NULL );
67-
68-
std::string cmd, sep;
69-
for( int i = 2; i < argc; ++i ) {
70-
cmd += sep + argv[i];
71-
sep = ' ';
72-
}
73-
int ret;
74-
auto overhead = timing::bench( [&]{
75-
// spinning
76-
for( auto i = 0; i < N; ++i )
77-
ret = system((cmd+"! 1> nul 2> nul").c_str());
78-
} );
79-
auto took = timing::bench( [&]{
80-
// avg time
81-
for( auto i = 0; i < N - 1; ++i )
82-
system((cmd+" 1> nul 2> nul").c_str());
83-
ret = system(cmd.c_str());
84-
} );
85-
std::cout << (std::abs(took - overhead) / N) << " s." << std::endl;
86-
87-
// append to 'bench.csv'
64+
// benchmark
65+
if( argc > 1 )
8866
{
89-
std::ofstream ofs( base("/bench.csv").c_str(), std::ios::binary | std::ios::app );
90-
if( ofs.good() ) {
91-
ofs << argv[2] << "," << ( std::abs(took - overhead) / N ) << std::endl;
67+
int N = 0;
68+
std::string cmd, sep, desc;
69+
for( int i = 1; i < argc; ++i ) {
70+
if( argv[i][0] >= '0' && argv[i][0] <= '9' ) {
71+
N = std::strtoul( argv[i], NULL, NULL );
72+
}
73+
else
74+
if( argv[i][0] == '/' && argv[i][1] == '/' ) {
75+
desc = &argv[i][2];
76+
}
77+
else {
78+
cmd += sep + argv[i];
79+
sep = ' ';
80+
81+
if( desc.empty() ) desc = argv[i];
82+
}
83+
}
84+
auto overhead = 0; // measure fib(0)
85+
auto took = timing::bench( [&]{
86+
// avg time
87+
for( auto i = 0; i < N - 1; ++i )
88+
system((cmd+" 1> nul 2> nul").c_str());
89+
ret = system(cmd.c_str());
90+
} );
91+
std::cout << (std::abs(took - overhead) / N) << " s." << std::endl;
92+
93+
// append to 'bench.csv'
94+
{
95+
std::ofstream ofs( base("/bench.csv").c_str(), std::ios::binary | std::ios::app );
96+
if( ofs.good() ) {
97+
ofs << desc << "," << ( std::abs(took - overhead) / N ) << std::endl;
98+
}
9299
}
93100
}
94101

@@ -118,12 +125,19 @@ int main( int argc, const char **argv ) {
118125

119126
bool operator <( const idx &other ) const {
120127
if( time < other.time ) return true;
121-
if( time > other.time ) return false;
122128
return name < other.name;
123129
}
130+
131+
bool operator==( const idx &other ) const {
132+
return name == other.name;
133+
}
134+
bool operator!=( const idx &other ) const {
135+
return name != other.name;
136+
}
124137
};
125138

126-
std::set< idx > all;
139+
std::map< std::string, float > unique;
140+
std::set< idx > sort;
127141

128142
{
129143
std::ifstream ifs( base("/bench.csv").c_str(), std::ios::binary);
@@ -137,28 +151,39 @@ int main( int argc, const char **argv ) {
137151
auto tokens = tokenize( line, "," );
138152
if( tokens.size() == 2 ) {
139153
if( tokens[0] == "fib" || tokens[0] == "fib.exe" ) tokens[0] = "c/vc";
140-
all.insert( idx { tokens[0], std::strtof( tokens[1].c_str(), NULL ) } );
154+
float time = std::strtof( tokens[1].c_str(), NULL );
155+
float prev = (unique[ tokens[0] ] = unique[ tokens[0] ]);
156+
unique[ tokens[0] ] = prev ? (std::min)( prev, time ) : time;
141157
}
142158
}
159+
for( auto &it : unique ) {
160+
sort.insert( idx{ it.first, it.second } );
161+
}
143162
}
144163

145-
#if 0
146-
auto min = float(all.rbegin()->time);
147-
#else
148-
auto cmin = all.begin(); //find("lua")->time; //float(all.begin()->time);
149-
while( cmin != all.end() && cmin->name != "lua" ) cmin++;
150-
auto min = float(cmin->time);
164+
auto min = float(sort.begin()->time);
165+
auto max = float(sort.rbegin()->time);
166+
167+
#if 1
168+
auto cmin = sort.begin(); //find("lua")->time; //float(sort.begin()->time);
169+
while( cmin != sort.end() && cmin->name.find("[lua]") == std::string::npos ) cmin++;
170+
min = float(cmin->time);
151171
#endif
152-
auto max = float(all.rbegin()->time);
153172

154173
std::ofstream ofs( base("BENCH.md").c_str(), std::ios::binary);
155174
ofs << "|Language|Time|Relative Lua speed|Score|" << std::endl;
156175
ofs << "|:-------|---:|:----------------:|----:|" << std::endl;
157-
for( auto &it : all ) {
176+
for( auto &it : sort ) {
158177
float speed = it.relative_speed(min, max);
159178
int score( speed );
179+
int factor( speed / 100 );
160180
speed = speed > 100 ? 100 : speed;
161-
ofs << '|' << it.name << "|" << it.time << " s.|![" << speed << "%](http://progressed.io/bar/" << int(speed) << ")|" << score << " pt|" << std::endl;
181+
if( factor > 1 ) {
182+
char buf[16]; sprintf(buf, "%02d", factor);
183+
ofs << '|' << it.name << "|" << it.time << " s.|![" << speed << "%](http://progressed.io/bar/" << int(speed) << "?title=x" << buf << ")|" << score << " pt|" << std::endl;
184+
} else {
185+
ofs << '|' << it.name << "|" << it.time << " s.|![" << speed << "%](http://progressed.io/bar/" << int(speed) << ")|" << score << " pt|" << std::endl;
186+
}
162187
}
163188
}
164189

bench.exe

3.5 KB
Binary file not shown.

gml/.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "linenoise"]
2+
path = linenoise
3+
url = https://github.com/antirez/linenoise.git

gml/Makefile

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
CC ?= clang
2+
COMPILER = $(shell $(CC) --version | head -1)
3+
OS = $(shell uname)
4+
CFLAGS = -std=gnu99 -Wall -Wextra -g3 -Ilinenoise -DGML_COMPILER="\"$(COMPILER)\"" -DGML_OS="\"$(OS)\"" -DGML_TYPE="\"development\""
5+
LDFLAGS = -lm
6+
SOURCES = lex.c list.c parse.c runtime.c builtin.c gml.c linenoise/linenoise.c
7+
OBJECTS = $(SOURCES:.c=.o)
8+
EXECUTABLE = gml
9+
PREFIX = /usr
10+
11+
all: $(SOURCES) $(EXECUTABLE)
12+
13+
$(EXECUTABLE): $(OBJECTS)
14+
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
15+
16+
.c.o:
17+
$(CC) -c $(CFLAGS) $< -o $@
18+
19+
clean:
20+
rm -rf $(OBJECTS) $(EXECUTABLE)
21+
22+
install: $(EXECUTABLE)
23+
install $(EXECUTABLE) $(PREFIX)/bin/
24+
25+
uninstall:
26+
rm -rf $(PREFIX)/bin/$(EXECUTABLE)

0 commit comments

Comments
 (0)