jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
#todo написати функцію на будь-якій мові програмування, яка приймає масив чисел і повертає той самий масив, але з усіма нулями, переміщеними в кінець, зберігаючи порядок ненульових елементів.
Наприклад: [0, 1] => [1, 0] [0, 1, 0] => [1, 0, 0] [0, 1, 0, 3, 12] => [1, 3, 12, 0, 0] [0, 12, 0, 1, 3] => [12, 1, 3, 0, 0] */
const n = 1000;
const arr00000 = (argN) => new Array(argN).fill(0);
const arr00001 = (argN) => {
const arr = new Array(argN).fill(0);
arr[argN - 1] = 1;
return arr;
};
const arr10000 = (argN) => {
const arr = new Array(argN).fill(0);
arr[0] = 1;
return arr;
};
const arr11111 = (argN) => new Array(argN).fill(1);
const arr11110 = (argN) => {
const arr = new Array(argN).fill(1);
arr[argN - 1] = 0;
return arr;
};
const arr01111 = (argN) => {
const arr = new Array(argN).fill(1);
arr[0] = 0;
return arr;
};
const arr01010 = (argN) => {
const arr = new Array(argN).fill(1);
for (let i = 0; i < argN; i++) {
if (i % 2 === 0) {
arr[i] = 0;
}
}
return arr;
};
Ready to run.
Test | Ops/sec | |
---|---|---|
Volodymyr_v1 |
| ready |
Volodymyr_chatGPT |
| ready |
DanielWright_v1 |
| ready |
Yura_v1 |
| ready |
MCLtd_v1 |
| ready |
MCLtd_chatGPT |
| ready |
Yura_byVolodymyr |
| ready |
Volodymyr_v2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.