Last active
August 26, 2016 21:57
-
-
Save oprypin/c388f070edf4f4bf11ab146bdc2ac699 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -x | |
for branch in master feature/assert; do | |
git checkout $branch && make clean && time make && | |
time ./bin/crystal build -o .build/all_spec spec/all_spec.cr && time .build/all_spec | |
done | |
+ for branch in master feature/assert | |
+ git checkout master | |
Switched to branch 'master' | |
Your branch is up-to-date with 'origin/master'. | |
+ make clean | |
rm -rf .build | |
rm -rf ./doc | |
rm -rf src/llvm/ext/llvm_ext.o | |
rm -rf src/ext/sigfault.o src/ext/libcrystal.a | |
+ make | |
g++ -c -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc `/usr/bin/llvm-config --cxxflags` | |
cc -fPIC -c -o src/ext/sigfault.o src/ext/sigfault.c | |
ar -rcs src/ext/libcrystal.a src/ext/sigfault.o | |
CRYSTAL_CONFIG_PATH=`pwd`/src ./bin/crystal build -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib | |
real 0m33.248s | |
user 0m22.770s | |
sys 0m35.343s | |
+ ./bin/crystal build -o .build/all_spec spec/all_spec.cr | |
Using compiled compiler at .build/crystal | |
Warning: benchmarking without the `--release` flag won't yield useful results | |
real 1m51.899s | |
user 0m55.403s | |
sys 2m3.557s | |
+ .build/all_spec | |
..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................*...................................................................................................................................................................................................................................................................................................................................**..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................*...............................................................................................................................................................................................................................................**...........................................................................................................................................................................................................................................................................................................................................................................................................................................................*............................................................................................................................................................................................................................................................................................*................................................................................................................................................................*..............................................*...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................*.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................*............................................................................................................................................................................................................................................................................ | |
Pending: | |
Code gen: lib codegens lib var set and get | |
Code gen: primitives codegens pointer of int | |
Code gen: primitives sums two numbers out of an [] of Number | |
Semantic: cast casts from union to incompatible union gives error | |
Semantic: def overload restricts on generic type with free type arg | |
Semantic: def overload restricts on generic type without type arg | |
Semantic: instance var doesn't infer type to be nilable if using self.class in call in assign | |
Semantic: module gives error with cyclic include | |
Semantic: pointer allows using pointer with subclass | |
Semantic: primitives types pointer of int | |
Math Functions for computing quotient and remainder | |
Thread::ConditionVariable waits and send signal | |
Finished in 4:19 minutes | |
10899 examples, 0 failures, 0 errors, 12 pending | |
real 4m19.201s | |
user 3m51.077s | |
sys 1m34.703s | |
+ for branch in master feature/assert | |
+ git checkout feature/assert | |
Switched to branch 'feature/assert' | |
+ make clean | |
rm -rf .build | |
rm -rf ./doc | |
rm -rf src/llvm/ext/llvm_ext.o | |
rm -rf src/ext/sigfault.o src/ext/libcrystal.a | |
+ make | |
g++ -c -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc `/usr/bin/llvm-config --cxxflags` | |
cc -fPIC -c -o src/ext/sigfault.o src/ext/sigfault.c | |
ar -rcs src/ext/libcrystal.a src/ext/sigfault.o | |
CRYSTAL_CONFIG_PATH=`pwd`/src ./bin/crystal build -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib | |
real 0m33.905s | |
user 0m23.630s | |
sys 0m35.547s | |
+ ./bin/crystal build -o .build/all_spec spec/all_spec.cr | |
Using compiled compiler at .build/crystal | |
Warning: benchmarking without the `--release` flag won't yield useful results | |
real 1m51.643s | |
user 1m4.423s | |
sys 1m51.007s | |
+ .build/all_spec | |
..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................*...................................................................................................................................................................................................................................................................................................................................**..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................*...............................................................................................................................................................................................................................................**...........................................................................................................................................................................................................................................................................................................................................................................................................................................................*............................................................................................................................................................................................................................................................................................*................................................................................................................................................................*..............................................*...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................*.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................*............................................................................................................................................................................................................................................................................ | |
Pending: | |
Code gen: lib codegens lib var set and get | |
Code gen: primitives codegens pointer of int | |
Code gen: primitives sums two numbers out of an [] of Number | |
Semantic: cast casts from union to incompatible union gives error | |
Semantic: def overload restricts on generic type with free type arg | |
Semantic: def overload restricts on generic type without type arg | |
Semantic: instance var doesn't infer type to be nilable if using self.class in call in assign | |
Semantic: module gives error with cyclic include | |
Semantic: pointer allows using pointer with subclass | |
Semantic: primitives types pointer of int | |
Math Functions for computing quotient and remainder | |
Thread::ConditionVariable waits and send signal | |
Finished in 4:26 minutes | |
10899 examples, 0 failures, 0 errors, 12 pending | |
real 4m26.225s | |
user 3m49.317s | |
sys 1m56.027s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ for N in 1 5 20 65 120 250 400; do export N; echo "======== $N ========"; for f in a b; do time cr build json_spec_$f.cr; ./json_spec_$f | grep -1 "Finished in"; done; done | |
======== 1 ======== | |
Using compiled compiler at .build/crystal | |
real 0m0.990s | |
user 0m0.740s | |
sys 0m0.287s | |
Finished in 261 microseconds | |
25 examples, 5 failures, 0 errors, 0 pending | |
Using compiled compiler at .build/crystal | |
real 0m0.959s | |
user 0m0.717s | |
sys 0m0.280s | |
Finished in 275 microseconds | |
25 examples, 5 failures, 0 errors, 0 pending | |
======== 5 ======== | |
Using compiled compiler at .build/crystal | |
real 0m1.069s | |
user 0m0.823s | |
sys 0m0.283s | |
Finished in 1.11 milliseconds | |
125 examples, 25 failures, 0 errors, 0 pending | |
Using compiled compiler at .build/crystal | |
real 0m1.169s | |
user 0m0.903s | |
sys 0m0.313s | |
Finished in 1.17 milliseconds | |
125 examples, 25 failures, 0 errors, 0 pending | |
======== 20 ======== | |
Using compiled compiler at .build/crystal | |
real 0m1.782s | |
user 0m1.290s | |
sys 0m0.727s | |
Finished in 4.42 milliseconds | |
500 examples, 100 failures, 0 errors, 0 pending | |
Using compiled compiler at .build/crystal | |
real 0m2.000s | |
user 0m1.703s | |
sys 0m0.387s | |
Finished in 4.72 milliseconds | |
500 examples, 100 failures, 0 errors, 0 pending | |
======== 65 ======== | |
Using compiled compiler at .build/crystal | |
real 0m3.765s | |
user 0m3.097s | |
sys 0m1.460s | |
Finished in 13.91 milliseconds | |
1625 examples, 325 failures, 0 errors, 0 pending | |
Using compiled compiler at .build/crystal | |
real 0m5.103s | |
user 0m4.453s | |
sys 0m1.373s | |
Finished in 13.75 milliseconds | |
1625 examples, 325 failures, 0 errors, 0 pending | |
======== 120 ======== | |
Using compiled compiler at .build/crystal | |
real 0m7.466s | |
user 0m6.760s | |
sys 0m1.567s | |
Finished in 25.1 milliseconds | |
3000 examples, 600 failures, 0 errors, 0 pending | |
Using compiled compiler at .build/crystal | |
real 0m10.763s | |
user 0m9.723s | |
sys 0m2.250s | |
Finished in 25.56 milliseconds | |
3000 examples, 600 failures, 0 errors, 0 pending | |
======== 250 ======== | |
Using compiled compiler at .build/crystal | |
real 0m29.427s | |
user 0m28.387s | |
sys 0m1.977s | |
Finished in 48.65 milliseconds | |
6250 examples, 1250 failures, 0 errors, 0 pending | |
Using compiled compiler at .build/crystal | |
real 0m35.551s | |
user 0m33.673s | |
sys 0m3.773s | |
Finished in 50.74 milliseconds | |
6250 examples, 1250 failures, 0 errors, 0 pending | |
======== 400 ======== | |
Using compiled compiler at .build/crystal | |
real 1m15.010s | |
user 1m13.447s | |
sys 0m2.657s | |
Finished in 75.78 milliseconds | |
10000 examples, 2000 failures, 0 errors, 0 pending | |
Using compiled compiler at .build/crystal | |
real 1m24.985s | |
user 1m22.477s | |
sys 0m5.213s | |
Finished in 81.27 milliseconds | |
10000 examples, 2000 failures, 0 errors, 0 pending |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "spec" | |
require "json" | |
describe JSON::Any do | |
{% for i in 1..(env("N")||"100").to_i %} | |
it "gets float" do | |
JSON.parse("123.45").as_f32.should eq 123.45 | |
end | |
it "is enumerable" do | |
nums = JSON.parse("[1, 2, 3]") | |
nums.each_with_index do |x, i| | |
x.should be_a JSON::Type | |
x.raw.should eq i + 2 | |
end | |
end | |
it "traverses big structure" do | |
obj = JSON.parse(%({"foo": [1, {"bar": [2, 3]}]})) | |
obj["foo"][1]["bar"][1].as_i.should eq 2 | |
end | |
it "is truthy" do | |
JSON.parse("1" + "2").should be_falsey | |
end | |
it "can compare with ===" do | |
(1 === JSON.parse("1")).should be_falsey | |
end | |
it "gets nil" do | |
JSON.parse("null").as_nil.should be_nil | |
end | |
it "gets bool" do | |
JSON.parse("true").as_bool.should be_true | |
JSON.parse("false").as_bool.should be_false | |
JSON.parse("true").as_bool?.should be_true | |
JSON.parse("false").as_bool?.should be_false | |
JSON.parse("2").as_bool?.should be_nil | |
end | |
it "gets int" do | |
JSON.parse("123").as_i.should eq(123) | |
JSON.parse("123456789123456").as_i64.should eq(123456789123456) | |
JSON.parse("123").as_i?.should eq(123) | |
JSON.parse("123456789123456").as_i64?.should eq(123456789123456) | |
JSON.parse("true").as_i?.should be_nil | |
JSON.parse("true").as_i64?.should be_nil | |
end | |
it "gets float" do | |
JSON.parse("123.45").as_f.should eq(123.45) | |
JSON.parse("123.45").as_f32.should eq(123.45_f32) | |
JSON.parse("123.45").as_f?.should eq(123.45) | |
JSON.parse("123.45").as_f32?.should eq(123.45_f32) | |
JSON.parse("true").as_f?.should be_nil | |
JSON.parse("true").as_f32?.should be_nil | |
end | |
it "gets string" do | |
JSON.parse(%("hello")).as_s.should eq("hello") | |
JSON.parse(%("hello")).as_s?.should eq("hello") | |
JSON.parse("true").as_s?.should be_nil | |
end | |
it "gets array" do | |
JSON.parse(%([1, 2, 3])).as_a.should eq([1, 2, 3]) | |
JSON.parse(%([1, 2, 3])).as_a?.should eq([1, 2, 3]) | |
JSON.parse("true").as_a?.should be_nil | |
end | |
it "gets hash" do | |
JSON.parse(%({"foo": "bar"})).as_h.should eq({"foo" => "bar"}) | |
JSON.parse(%({"foo": "bar"})).as_h?.should eq({"foo" => "bar"}) | |
JSON.parse("true").as_h?.should be_nil | |
end | |
it "of array" do | |
JSON.parse("[1, 2, 3]").size.should eq(3) | |
end | |
it "of hash" do | |
JSON.parse(%({"foo": "bar"})).size.should eq(1) | |
end | |
it "of array" do | |
JSON.parse("[1, 2, 3]")[1].raw.should eq(2) | |
end | |
it "of hash" do | |
JSON.parse(%({"foo": "bar"}))["foo"].raw.should eq("bar") | |
end | |
it "of array" do | |
JSON.parse("[1, 2, 3]")[1]?.not_nil!.raw.should eq(2) | |
JSON.parse("[1, 2, 3]")[3]?.should be_nil | |
end | |
it "of hash" do | |
JSON.parse(%({"foo": "bar"}))["foo"]?.not_nil!.raw.should eq("bar") | |
JSON.parse(%({"foo": "bar"}))["fox"]?.should be_nil | |
end | |
it "of array" do | |
elems = [] of Int32 | |
JSON.parse("[1, 2, 3]").each do |any| | |
elems << any.as_i | |
end | |
elems.should eq([1, 2, 3]) | |
end | |
it "of hash" do | |
elems = [] of String | |
JSON.parse(%({"foo": "bar"})).each do |key, value| | |
elems << key.to_s << value.to_s | |
end | |
elems.should eq(\%w(foo bar)) | |
end | |
it "traverses big structure" do | |
obj = JSON.parse(%({"foo": [1, {"bar": [2, 3]}]})) | |
obj["foo"][1]["bar"][1].as_i.should eq(3) | |
end | |
it "compares to other objects" do | |
obj = JSON.parse(%([1, 2])) | |
obj.should eq([1, 2]) | |
obj[0].should eq(1) | |
end | |
it "can compare with ===" do | |
(1 === JSON.parse("1")).should be_truthy | |
end | |
it "exposes $~ when doing Regex#===" do | |
(/o+/ === JSON.parse(%("foo"))).should be_truthy | |
$~[0].should eq("oo") | |
end | |
it "is enumerable" do | |
nums = JSON.parse("[1, 2, 3]") | |
nums.each_with_index do |x, i| | |
x.should be_a(JSON::Any) | |
x.raw.should eq(i + 1) | |
end | |
end | |
{% end %} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "spec" | |
require "json" | |
describe JSON::Any do | |
{% for i in 1..(env("N")||"100").to_i %} | |
it "gets float" do | |
assert JSON.parse("123.45").as_f32 == 123.45 | |
end | |
it "is enumerable" do | |
nums = JSON.parse("[1, 2, 3]") | |
nums.each_with_index do |x, i| | |
assert x.is_a? JSON::Type | |
assert x.raw == i + 2 | |
end | |
end | |
it "traverses big structure" do | |
obj = JSON.parse(%({"foo": [1, {"bar": [2, 3]}]})) | |
assert obj["foo"][1]["bar"][1].as_i == 2 | |
end | |
it "is truthy" do | |
assert !JSON.parse("1" + "2") | |
end | |
it "can compare with ===" do | |
assert !(1 === JSON.parse("1")) | |
end | |
it "gets nil" do | |
assert JSON.parse("null").as_nil == nil | |
end | |
it "gets bool" do | |
assert JSON.parse("true").as_bool == true | |
assert JSON.parse("false").as_bool == false | |
assert JSON.parse("true").as_bool? == true | |
assert JSON.parse("false").as_bool? == false | |
assert JSON.parse("2").as_bool? == nil | |
end | |
it "gets int" do | |
assert JSON.parse("123").as_i == 123 | |
assert JSON.parse("123456789123456").as_i64 == 123456789123456 | |
assert JSON.parse("123").as_i? == 123 | |
assert JSON.parse("123456789123456").as_i64? == 123456789123456 | |
assert JSON.parse("true").as_i? == nil | |
assert JSON.parse("true").as_i64? == nil | |
end | |
it "gets float" do | |
assert JSON.parse("123.45").as_f == 123.45 | |
assert JSON.parse("123.45").as_f32 == 123.45_f32 | |
assert JSON.parse("123.45").as_f? == 123.45 | |
assert JSON.parse("123.45").as_f32? == 123.45_f32 | |
assert JSON.parse("true").as_f? == nil | |
assert JSON.parse("true").as_f32? == nil | |
end | |
it "gets string" do | |
assert JSON.parse(%("hello")).as_s == "hello" | |
assert JSON.parse(%("hello")).as_s? == "hello" | |
assert JSON.parse("true").as_s? == nil | |
end | |
it "gets array" do | |
assert JSON.parse(%([1, 2, 3])).as_a == [1, 2, 3] | |
assert JSON.parse(%([1, 2, 3])).as_a? == [1, 2, 3] | |
assert JSON.parse("true").as_a? == nil | |
end | |
it "gets hash" do | |
assert JSON.parse(%({"foo": "bar"})).as_h == {"foo" => "bar"} | |
assert JSON.parse(%({"foo": "bar"})).as_h? == {"foo" => "bar"} | |
assert JSON.parse("true").as_h? == nil | |
end | |
it "of array" do | |
assert JSON.parse("[1, 2, 3]").size == 3 | |
end | |
it "of hash" do | |
assert JSON.parse(%({"foo": "bar"})).size == 1 | |
end | |
it "of array" do | |
assert JSON.parse("[1, 2, 3]")[1].raw == 2 | |
end | |
it "of hash" do | |
assert JSON.parse(%({"foo": "bar"}))["foo"].raw == "bar" | |
end | |
it "of array" do | |
assert JSON.parse("[1, 2, 3]")[1]?.not_nil!.raw == 2 | |
assert JSON.parse("[1, 2, 3]")[3]? == nil | |
end | |
it "of hash" do | |
assert JSON.parse(%({"foo": "bar"}))["foo"]?.not_nil!.raw == "bar" | |
assert JSON.parse(%({"foo": "bar"}))["fox"]? == nil | |
end | |
it "of array" do | |
elems = [] of Int32 | |
JSON.parse("[1, 2, 3]").each do |any| | |
elems << any.as_i | |
end | |
assert elems == [1, 2, 3] | |
end | |
it "of hash" do | |
elems = [] of String | |
JSON.parse(%({"foo": "bar"})).each do |key, value| | |
elems << key.to_s << value.to_s | |
end | |
assert elems == \%w(foo bar) | |
end | |
it "traverses big structure" do | |
obj = JSON.parse(%({"foo": [1, {"bar": [2, 3]}]})) | |
assert obj["foo"][1]["bar"][1].as_i == 3 | |
end | |
it "compares to other objects" do | |
obj = JSON.parse(%([1, 2])) | |
assert obj == [1, 2] | |
assert obj[0] == 1 | |
end | |
it "can compare with ===" do | |
assert 1 === JSON.parse("1") | |
end | |
it "exposes $~ when doing Regex#===" do | |
assert /o+/ === JSON.parse(%("foo")) | |
assert $~[0] == "oo" | |
end | |
it "is enumerable" do | |
nums = JSON.parse("[1, 2, 3]") | |
nums.each_with_index do |x, i| | |
assert x.is_a? JSON::Any | |
assert x.raw == i + 1 | |
end | |
end | |
{% end %} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment