Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
465d7a23
Commit
465d7a23
authored
Apr 24, 2015
by
furunkel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add build files for benchmarkings; add mandelbrot benchmark
parent
96d66f6d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
150 additions
and
32 deletions
+150
-32
benchmark/bm_so_mandelbrot.rb
benchmark/bm_so_mandelbrot.rb
+64
-0
benchmark/build_config_boxing.rb
benchmark/build_config_boxing.rb
+28
-0
benchmark/build_config_cc.rb
benchmark/build_config_cc.rb
+13
-0
benchmark/fib.rb
benchmark/fib.rb
+1
-2
benchmark/plot.gpl
benchmark/plot.gpl
+5
-0
tasks/benchmark.rake
tasks/benchmark.rake
+39
-30
No files found.
benchmark/bm_so_mandelbrot.rb
0 → 100644
View file @
465d7a23
# The Computer Language Benchmarks Game
# http://shootout.alioth.debian.org/
#
# contributed by Karl von Laudermann
# modified by Jeremy Echols
size
=
1000
# ARGV[0].to_i
puts
"P4
\n
#{
size
}
#{
size
}
"
ITER
=
49
# Iterations - 1 for easy for..in looping
LIMIT_SQUARED
=
4.0
# Presquared limit
byte_acc
=
0
bit_num
=
0
count_size
=
size
-
1
# Precomputed size for easy for..in looping
def
id
(
x
)
x
end
# For..in loops are faster than .upto, .downto, .times, etc.
for
y
in
0
..
count_size
for
x
in
0
..
count_size
zr
=
0.0
zi
=
0.0
cr
=
(
2.0
*
x
/
size
)
-
1.5
ci
=
(
2.0
*
y
/
size
)
-
1.0
escape
=
false
# To make use of the for..in code, we use a dummy variable,
# like one would in C
for
dummy
in
0
..
ITER
tr
=
zr
*
zr
-
zi
*
zi
+
cr
ti
=
2
*
zr
*
zi
+
ci
zr
,
zi
=
tr
,
ti
if
(
zr
*
zr
+
zi
*
zi
)
>
LIMIT_SQUARED
escape
=
true
break
end
end
# byte_acc = (byte_acc << 1) | (escape ? 0b0 : 0b1)
byte_acc
=
(
byte_acc
*
2
)
|
(
escape
?
0b0
:
0b1
)
# byte_acc = (byte_acc * 2) + (escape ? 0b0 : 0b1)
# byte_acc = (byte_acc * 2) + 1
bit_num
+=
1
# Code is very similar for these cases, but using separate blocks
# ensures we skip the shifting when it's unnecessary, which is most cases.
if
(
bit_num
==
8
)
# print byte_acc.chr
byte_acc
=
0
bit_num
=
0
elsif
(
x
==
count_size
)
byte_acc
<<=
(
8
-
bit_num
)
# byte_acc = byte_acc << (8 - bit_num)
# print byte_acc.chr
byte_acc
=
0
bit_num
=
0
end
end
end
benchmark/build_config_boxing.rb
0 → 100644
View file @
465d7a23
MRuby
::
Build
.
new
do
|
conf
|
toolchain
:gcc
end
MRuby
::
Build
.
new
(
'no_boxing'
)
do
|
conf
|
toolchain
:gcc
conf
.
gembox
'default'
end
MRuby
::
Build
.
new
(
'word_boxing'
)
do
|
conf
|
toolchain
:gcc
conf
.
gembox
'default'
conf
.
compilers
.
each
do
|
c
|
c
.
defines
+=
%w(MRB_WORD_BOXING)
end
end
MRuby
::
Build
.
new
(
'nan_boxing'
)
do
|
conf
|
toolchain
:gcc
conf
.
gembox
'default'
conf
.
compilers
.
each
do
|
c
|
c
.
defines
+=
%w(MRB_NAN_BOXING)
end
end
benchmark/build_config_cc.rb
0 → 100644
View file @
465d7a23
MRuby
::
Build
.
new
do
|
conf
|
toolchain
:gcc
end
MRuby
::
Build
.
new
(
'gcc'
)
do
|
conf
|
toolchain
:gcc
conf
.
gembox
'default'
end
MRuby
::
Build
.
new
(
'clang'
)
do
|
conf
|
toolchain
:clang
conf
.
gembox
'default'
end
benchmark/fib
39
.rb
→
benchmark/fib.rb
View file @
465d7a23
# Fib 39
def
fib
n
return
n
if
n
<
2
fib
(
n
-
2
)
+
fib
(
n
-
1
)
end
puts
fib
(
3
9
)
puts
fib
(
3
7
)
benchmark/plot.gpl
0 → 100644
View file @
465d7a23
set yrange [0:]
set terminal pdf
set xtics rotate by -45
set style histogram errorbars gap 2 lw 1
set style fill solid border -1
tasks/benchmark.rake
View file @
465d7a23
module
MRuby
BENCHMARK_REPEAT
=
2
BENCHMARK_REPEAT
=
4
end
$dat_files
=
[]
...
...
@@ -15,10 +15,19 @@ end
def
plot
opts_file
=
"
#{
MRUBY_ROOT
}
/benchmark/plot.gpl"
opts
=
File
.
read
(
opts_file
).
each_line
.
to_a
.
map
(
&
:strip
).
join
(
';'
)
opts
+=
';plot '
dat_files
=
$dat_files
.
group_by
{
|
f
|
File
.
dirname
(
f
).
split
(
File
::
SEPARATOR
)[
-
1
]}
build_config_name
=
if
ENV
[
'MRUBY_CONFIG'
]
File
.
basename
(
ENV
[
'MRUBY_CONFIG'
],
'.rb'
).
gsub
(
'build_config_'
,
''
)
else
"bm"
end
opts
+=
";set output '
#{
File
.
join
(
MRUBY_ROOT
,
'benchmark'
,
"
#{
build_config_name
}
.pdf"
)
}
'"
opts
+=
';plot '
opts
+=
dat_files
.
keys
.
map
do
|
data_file
|
%Q['-' u 2:3:4:xtic(1) w hist title columnheader(1)]
end
.
join
(
','
)
...
...
@@ -28,7 +37,7 @@ def plot
IO
.
popen
(
cmd
,
'w'
)
do
|
p
|
dat_files
.
each
do
|
target_name
,
bm_files
|
p
.
puts
target_name
p
.
puts
target_name
.
gsub
(
'_'
,
'-'
)
bm_files
.
each
do
|
bm_file
|
p
.
write
File
.
read
(
bm_file
)
end
...
...
@@ -39,33 +48,33 @@ end
MRuby
.
each_target
do
|
target
|
mruby_path
=
"
#{
target
.
build_dir
}
/bin/mruby"
if
File
.
file?
mruby_path
bm_files
.
each
do
|
bm_file
|
bm_name
=
File
.
basename
bm_file
,
".rb"
dat_dir
=
File
.
join
(
'benchmark'
,
target
.
name
)
dat_file
=
File
.
join
(
dat_dir
,
"
#{
bm_name
}
.dat"
)
$dat_files
<<
dat_file
directory
dat_dir
file
dat_file
=>
[
bm_file
,
dat_dir
]
do
|
task
|
print
bm_name
puts
"..."
data
=
(
0
...
MRuby
::
BENCHMARK_REPEAT
).
map
do
|
n
|
str
=
%x{(time -f "%e %S %U"
#{
mruby_path
}
#{
bm_file
}
) 2>&1 >/dev/null}
str
.
split
(
' '
).
map
(
&
:to_f
)
end
File
.
open
(
task
.
name
,
"w"
)
do
|
f
|
data
=
data
.
map
{
|
_
,
r
,
s
|
(
r
+
s
)
/
2.0
}
min
=
data
.
min
max
=
data
.
max
avg
=
data
.
inject
(
&
:
+
)
/
data
.
size
f
.
puts
"
#{
bm_name
.
gsub
(
'_'
,
'-'
)
}
#{
avg
}
#{
min
}
#{
max
}
"
end
next
if
target
.
name
==
'host'
mruby_bin
=
"
#{
target
.
build_dir
}
/bin/mruby"
bm_files
.
each
do
|
bm_file
|
bm_name
=
File
.
basename
bm_file
,
".rb"
dat_dir
=
File
.
join
(
'benchmark'
,
target
.
name
)
dat_file
=
File
.
join
(
dat_dir
,
"
#{
bm_name
}
.dat"
)
$dat_files
<<
dat_file
directory
dat_dir
file
dat_file
=>
[
bm_file
,
dat_dir
,
mruby_bin
]
do
|
task
|
print
bm_name
puts
"..."
data
=
(
0
...
MRuby
::
BENCHMARK_REPEAT
).
map
do
|
n
|
str
=
%x{(time -f "%e %S %U"
#{
mruby_bin
}
#{
bm_file
}
) 2>&1 >/dev/null}
str
.
split
(
' '
).
map
(
&
:to_f
)
end
File
.
open
(
task
.
name
,
"w"
)
do
|
f
|
data
=
data
.
map
{
|
_
,
r
,
s
|
(
r
+
s
)
/
2.0
}
min
=
data
.
min
max
=
data
.
max
avg
=
data
.
inject
(
&
:
+
)
/
data
.
size
f
.
puts
"
#{
bm_name
.
gsub
(
'_'
,
'-'
)
}
#{
avg
}
#{
min
}
#{
max
}
"
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment