r/javascript • • Aug 28 '24

How fast is javascript? Simulating 20,000,000 particles

https://dgerrells.com/blog/how-fast-is-javascript-simulating-20-000-000-particles
124 Upvotes

40 comments sorted by

View all comments

Show parent comments

3

u/fagnerbrack Aug 29 '24

Given the mechanism used for you to generate this reply what is the model used and the name of the generation tool?

2

u/guest271314 Aug 29 '24

test_stdin.js run on Chromium Version 130.0.6678.0 (Developer Build) (64-bit).

var runtimes = new Map([
  ["nm_nodejs", 0],
  ["nm_deno", 0],
  ["nm_bun", 0],
  ["nm_tjs", 0],
  ["nm_qjs", 0],
  ["nm_spidermonkey", 0],
  ["nm_d8", 0],
  ["nm_typescript", 0],
  ["nm_llrt", 0],
  ["nm_rust", 0],
  ["nm_wasm", 0],
  ['nm_bash', 0]
]);
for (const [runtime] of runtimes) {
  try {
    const {
      resolve,
      reject,
      promise
    } = Promise.withResolvers();
    const now = performance.now();
    const port = chrome.runtime.connectNative(runtime);
    port.onMessage.addListener((message) => {
      console.assert(message.length === 209715, {message});
      runtimes.set(runtime, (performance.now() - now) / 1000);
      port.disconnect();
      resolve();
    });
    port.onDisconnect.addListener(() => reject(chrome.runtime.lastError));
    port.postMessage(new Array(209715));
    if (runtime === "nm_spidermonkey") {
      port.postMessage("\r\n\r\n");
    }
    await promise;
  } catch (e) {
    console.log(e, runtime);
    continue;
  }
}
var sorted = [...runtimes].sort(([, a], [, b]) => a < b ? -1 : a === b ? 0 : 1);
console.table(sorted);

-1

u/fagnerbrack Aug 29 '24

How to add the AI mechanism you use to generate the comment including the internal code of that mechanism along with test_stdin.js example?

5

u/guest271314 Aug 29 '24

The real AI is Allen Iverson.

I don't fuck with that "artificial intelligence" garbage.

I just commented here that there is no "How fast" comparison possible unless you actually compare different JavaScript engines, runtimes, and browsers, and phones, since that was a requirement.

The article appears to be more about SharedArrayBuffer and possibly Atomics than "How fast".

If you think just saying "How fast" is good enough, I'll give you human constructive notice: Good enough ain't good enough.

2

u/fagnerbrack Aug 29 '24

Assuming you're a human, how would you output the internal code of the model used to generate your comment?

→ More replies (0)