Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/testing/xpcshell/node-ws/bench/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  speed.js

  Sprache: JAVA
 

'use strict';

const cluster = require('cluster');
const http = require('http');

const WebSocket = require('..');

const port = 8181;
const path = '';
// const path = '/tmp/wss.sock';

if (cluster.isMaster) {
  const server = http.createServer();
  const wss = new WebSocket.Server({
    maxPayload: 600 * 1024 * 1024,
    perMessageDeflate: false,
    clientTracking: false,
    server
  });

  wss.on('connection', (ws) => {
    ws.on('message', (data, isBinary) => {
      ws.send(data, { binary: isBinary });
    });
  });

  server.listen(path ? { path } : { port }, () => cluster.fork());

  cluster.on('exit', () => {
    wss.close();
    server.close();
  });
else {
  const configs = [
    [true1000064],
    [true500016 * 1024],
    [true1000128 * 1024],
    [true1001024 * 1024],
    [true1500 * 1024 * 1024],
    [false1000064],
    [false500016 * 1024],
    [false1000128 * 1024],
    [false1001024 * 1024]
  ];

  const roundPrec = (num, prec) => {
    const mul = Math.pow(10, prec);
    return Math.round(num * mul) / mul;
  };

  const humanSize = (bytes) => {
    if (bytes >= 1073741824return roundPrec(bytes / 10737418242) + ' GiB';
    if (bytes >= 1048576return roundPrec(bytes / 10485762) + ' MiB';
    if (bytes >= 1024return roundPrec(bytes / 10242) + ' KiB';
    return roundPrec(bytes, 2) + ' B';
  };

  const largest = configs.reduce(
    (prev, curr) => (curr[2] > prev ? curr[2] : prev),
    0
  );
  console.log('Generating %s of test data...', humanSize(largest));
  const randomBytes = Buffer.allocUnsafe(largest);

  for (let i = 0; i < largest; ++i) {
    randomBytes[i] = ~~(Math.random() * 127);
  }

  console.log(`Testing ws on ${path || '[::]:' + port}`);

  const runConfig = (useBinary, roundtrips, size, cb) => {
    const data = randomBytes.slice(0, size);
    const url = path ? `ws+unix://${path}` : `ws://localhost:${port}`;
    const ws = new WebSocket(url, {
      maxPayload: 600 * 1024 * 1024
    });
    let roundtrip = 0;
    let time;

    ws.on('error', (err) => {
      console.error(err.stack);
      cluster.worker.disconnect();
    });
    ws.on('open', () => {
      time = process.hrtime();
      ws.send(data, { binary: useBinary });
    });
    ws.on('message', () => {
      if (++roundtrip !== roundtrips)
        return ws.send(data, { binary: useBinary });

      let elapsed = process.hrtime(time);
      elapsed = elapsed[0] * 1e9 + elapsed[1];

      console.log(
        '%d roundtrips of %s %s data:\t%ss\t%s',
        roundtrips,
        humanSize(size),
        useBinary ? 'binary' : 'text',
        roundPrec(elapsed / 1e9, 1),
        humanSize(((size * 2 * roundtrips) / elapsed) * 1e9) + '/s'
      );

      ws.close();
      cb();
    });
  };

  (function run() {
    if (configs.length === 0return cluster.worker.disconnect();
    const config = configs.shift();
    config.push(run);
    runConfig.apply(null, config);
  })();
}

Messung V0.5 in Prozent
C=93 H=95 G=93

¤ Dauer der Verarbeitung: 0.9 Sekunden  (vorverarbeitet am  2026-06-04) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.