Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

1 billion loop iterations. 4 languages. I wrote the same code in js, python, go, and c. Timed executions on a digital ocean dedicated cpu vm, and here are the visualized results. Not all programming languages are created equal!

1,202,591 görüntüleme • 1 yıl önce •via X (Twitter)

11 Yorum

Ben Dicken profil fotoğrafı
Ben Dicken1 yıl önce

The visualization and code snippets for each language can be found here:

Wes Bos profil fotoğrafı
Wes Bos1 yıl önce

gonna remember this next time i need to loop over 1 billion things in a nested for loop in JS

Ben Dicken profil fotoğrafı
Ben Dicken1 yıl önce

Might need it next time you SELECT * FROM user;

Andrew — e/acc profil fotoğrafı
Andrew — e/acc1 yıl önce

in the javascript you should declare the for loop variable j outside the nested loop so it happens once. this will greatly reduce the execution time (per console tests). using "let" function scopes the declaration to inside the nested loop. try:

Ben Dicken profil fotoğrafı
Ben Dicken1 yıl önce

Good idea.

Handika Wisnu profil fotoğrafı
Handika Wisnu1 yıl önce

Redid the benchmark with a twist: added Rust and Zig, compiled Python using Codon (C++ based Python-compiler).

Ben Dicken profil fotoğrafı
Ben Dicken1 yıl önce

Crazy fast! What hardware?

Holly Guevara profil fotoğrafı
Holly Guevara1 yıl önce

the javascript community will never recover from this

Ben Dicken profil fotoğrafı
Ben Dicken1 yıl önce

Never ever

Simon profil fotoğrafı
Simon1 yıl önce

time node test.js ~3.04s time bun test.js ~4.14s time deno test.js ~3.02s time pypy ~2.46s time python ~99.29s (python3) This was tested on a M1 Max 64GB

Ben Dicken profil fotoğrafı
Ben Dicken1 yıl önce

That python3 number though 👀

Benzer Videolar