japaric-archived / euler_criterion.rs

Benchmark Project Euler solutions written in several programming languages using Criterion
Apache License 2.0
10 stars 4 forks source link

Crystal programming language #13

Open 5nyper opened 9 years ago

5nyper commented 9 years ago

Are you accepting new languages to the benchmarks? if so, I'll be happy to add the parts to add the Crystal programming language - http://crystal-lang.org

japaric commented 9 years ago

Are you accepting new languages to the benchmarks?

Yes!

I'll be happy to add the parts to add the Crystal programming language

Awesome!

I've quickly updated [1] the CLI tool that runs the benchmarks to work with the latest Rust nigthly. And I've also added "support" for the Crystal lang (see 7e0ccfe8d6f40da2440fc9ad450eb33dac5be0b8). What needs to be done right now is write the "template" program in crystal.

All the benchmark programs must adhere to this specification:

The template program follows this spec, but doesn't actually solve any problem (the "solution" is just an empty function). Check the template programs in other languages.

The important bit here is that the time must be measured using a monotonic timer. I don't know if Crystal has access to one in its stdlib. If it doesn't we can use librt's clock_gettime via FFI (see Python's template).

After we write the template program, we can easily add solutions to problems by copying the template into the problems/$ID folder and changing the solution function. Then you just call make bench to run the benchmarks [2].

[1] The tool is written in old Rust and panic!s a lot. I'll probably rewrite it with better error handling and diagnostics. [2] make bench will run all the benchmarks (all the problem and all the languages) by default. And it will panic if a compiler/interpreter is missing (see [1]). You can "disable" other languages by removing (or changing the extension of) the corresponding json file from the languages directory.

5nyper commented 9 years ago

I'll get right on writing a template program! Also, should the compiler flag be --release for optimizations?

japaric commented 9 years ago

@Ap0ph1s Nice

Also, should the compiler flag be --release for optimizations?

If it adds optimizations, yes. Just add the flag to this vector

(FYI, rewriting the CLI tool at the moment, will open a PR soon)