Crystal Lang SPEED TEST: Slick as Ruby, Fast as C?

preview_player
Показать описание
My apologies for the very similar uploads. It was brought to my attention in the last video that I did not give Crystal a fair shot at competing in a speed test.

In this video, we take a look at the speed of Crystal, optimized and not, as well as the speed of c, optimized and not as well.

If you would like to run this speed test on your own machine, here is a link to where you can download the code:

Let me know if you have any questions!
Thanks for watching and be safe!
Рекомендации по теме
Комментарии
Автор

Very interesting video. Anyway, the real reason why you should take Crystal into consideration is not its speed: it is its ease of use. It is quite hard to find a language that is as expressive and as easy to use as Python or Ruby while still being a compiled language. The best way to understand it is to multiplicate the execution time of a program by its development time. Not many languages can actually compare with Crystal if you take into account both sides of the software development problem.

AlessandroBottoni
Автор

I don't know what crystal are used for unless at the webdev field, i really love ruby, and crystal are using their syntaxes-like inside of. I want to try crystal for use in gamedev, but unfortunately there is no game engines that using it right now.

ArcWeltraumpert
Автор

i would like to see this language to pickup momentum

anselminos
Автор

I am pretty sure that Crystal was "faster" than C because the Crystal compiler figure out that you run a pure function that takes a constant and their return never gets usted, so the compiler conclude that it can be removed from the final productos without affect the result, so the Crystal binary is faster because is a void program of the equivalent in C:

int main() {
return 0;
}

engelsteinberg
Автор

By default with no args GCC will do some optimisation too. You'd need to compile with an optimisation level of 0 to get the C version with no optimisations

NickWebster
Автор

You shouldn't use a script to micro-benchmark. You'd be including startup time.(latency vs. throughput).

BoyoWhoGoesPoyo
Автор

Kind request: Please redo the first video with all the other languages and include also JavaScript since it is the main killer of Ruby currently. Crystal+Amber could be the savior for Ruby+Rails people who currently are forced to move over to JavaScript+Node due to performance issues of Ruby+Rails for real-time applications. Crystal+Amber could be the solution and such a video of you would be extremely interesting for the Ruby+Rails community!!
And if you could also add Go it would be even greater!

berlinerfamily
Автор

Some tips:

If you are using the latest version of Bash, use the EPOCHREALTIME variable in place of the `time` binary, as this will permit microsecond precision.

e.g.

micros_mattscripts()
{
[[ ! -f "$1" ]] && return 1 ;

local -r T0=$EPOCHREALTIME ; # CLOCK ON

command "$1";

local -r T1=$EPOCHREALTIME ; # CLOCK OFF

local -r tmp_time="/tmp/mtime.$T0";

> "$tmp_time" <<< "$T1 - $T0" /usr/bin/bc -l ;
< "$tmp_time" read -r seconds ;

printf "execd '$1' in $seconds s\n";

/usr/bin/rm "$tmp_time";
};

I have assumed that your version of Fedora includes the `bc` binary.

Also, avoid calling binaries in your scripts as much as possible. C and C++ programs always require between 0.001 and 0.003 s before entering main. Putting binaries in loops is the quickest way to write a slow script; always prefer language builtins where available. Some useful Bash builtins that are not enabled by default are: `realpath`, `head`, `id`, `ln`, `logname`, `mkdir`, `pathchk`, `print`, `rmdir`, `sleep`, `tee`, `tty`, `uname`, `unlink`, `whoami`. Each of these can be enabled like: `enable -f realpath realpath`, and generally behave identically to the programs they share names with.

technologicalwaste
Автор

Your Linux distro looks really good, what are you using?

franzify
Автор

What is the actual goal of crystal? Is it only for web, or does it support embedded development?

mtmow
Автор

I wrote the same code in Processing language and after running it a 1000 times it averages at 0.0264 seconds on a Ryzen 97850x.

prietjepruck
Автор

How about comparing Python with different interpreters like PyPy and maybe CPython? It still wouldn't be as fast as compiled languages but it should be faster than native Python

krists
Автор

how about 1 000 000 elements? :) Recently I tried to write 2 exactly equal neuro-nets with Python (with numpy) and C. C showed like 58 times faster for 1 000 000 iterations of learning :)

lvqmfjz