Загрузка видео...

Не удалось загрузить видео

На главную

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 просмотров • 1 год назад •via X (Twitter)

Комментарии: 11

Фото профиля Ben Dicken
Ben Dicken1 год назад

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

Фото профиля Wes Bos
Wes Bos1 год назад

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

Фото профиля Ben Dicken
Ben Dicken1 год назад

Might need it next time you SELECT * FROM user;

Фото профиля Andrew — e/acc
Andrew — e/acc1 год назад

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
Ben Dicken1 год назад

Good idea.

Фото профиля Handika Wisnu
Handika Wisnu1 год назад

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

Фото профиля Ben Dicken
Ben Dicken1 год назад

Crazy fast! What hardware?

Фото профиля Holly Guevara
Holly Guevara1 год назад

the javascript community will never recover from this

Фото профиля Ben Dicken
Ben Dicken1 год назад

Never ever

Фото профиля Simon
Simon1 год назад

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
Ben Dicken1 год назад

That python3 number though 👀

Похожие видео