<commit_before><!--
Copyright 2013, Google Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

    * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
    * Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<html>
<head>
<title>WebSocket benchmark</title>
<script src="util.js"></script>
<script>
// Namespace for holding globals.
var benchmark = {};

var SEND_PARAMETER = {
  numSockets: 1,
  // Initial size of messages.
  startSize: 10 * 1024,
  // Stops benchmark when the size of message exceeds this threshold.
  stopThreshold: 100000 * 1024,
  // If the size of each message is small, send/receive multiple messages until
  // the sum of sizes reaches this threshold.
  minTotal: 100000 * 1024,
  multipliers: [5, 2],
};

var RECEIVE_PARAMETER = {
  numSockets: 1,
  startSize: 10 * 1024,
  stopThreshold: 100000 * 1024,
  minTotal: 100000 * 1024,
  multipliers: [5, 2],
};

var sockets = [];
var numEstablishedSockets = 0;

var addressBox = null;

var timerID = null;

benchmark.startTimeInMs = 0;

var totalSize = 0;
var totalReplied = 0;

function destroySocket(socket) {
  socket.onopen = function() {};
  socket.onmessage = function() {};
  socket.onerror = function() {};
  socket.onclose = function() {};
  socket.close();
}

function destroyAllSockets() {
  for (var i = 0; i < sockets.length; ++i) {
    destroySocket(sockets[i]);
  }
  sockets = [];
}

function sendBenchmarkStep(size, multiplierIndex, parameter, config) {
  if (size > parameter.stopThreshold) {
    addToLog('Finished');
    destroyAllSockets();
    return;
  }

  var onMessageHandler = function(event) {
    if (!verifyAcknowledgement(event.data, size)) {
      destroyAllSockets();
      return;
    }

    totalReplied += size;

    if (totalReplied < totalSize) {
      return;
    }

    calculateAndLogResult(
        size, benchmark.startTimeInMs, totalSize, config.printSize);

    timerID = setTimeout(
        sendBenchmarkStep,
        0,
        size * parameter.multipliers[multiplierIndex],
        (multiplierIndex + 1) % parameter.multipliers.length,
        parameter,
        config);
  };

  for (var i = 0; i < sockets.length; ++i) {
    var socket = sockets[i];
    socket.onmessage = onMessageHandler;
  }

  benchmark.startTimeInMs = getTimeStamp();

  totalReplied = 0;

  totalSize = 0;

  var socketIndex = 0;
  while (totalSize < parameter.minTotal) {
    var buffer = new ArrayBuffer(size);

    fillArrayBuffer(buffer, 0x61);

    var command = ['send']
    if (config.verifyData)
    command.push('1')
    else
    command.push('0')
    sockets[socketIndex].send(command.join(' '));
    sockets[socketIndex].send(buffer);
    socketIndex = (socketIndex + 1) % sockets.length;

    totalSize += size;
  }
}

function receiveBenchmarkStep(size, multiplierIndex, parameter, config) {
  if (size > parameter.stopThreshold) {
    addToLog('Finished');<commit_msg>Fix indentation in benchmark.html<commit_after><!--
Copyright 2013, Google Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

    * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
    * Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<html>
<head>
<title>WebSocket benchmark</title>
<script src="util.js"></script>
<script>
// Namespace for holding globals.
var benchmark = {};

var SEND_PARAMETER = {
  numSockets: 1,
  // Initial size of messages.
  startSize: 10 * 1024,
  // Stops benchmark when the size of message exceeds this threshold.
  stopThreshold: 100000 * 1024,
  // If the size of each message is small, send/receive multiple messages until
  // the sum of sizes reaches this threshold.
  minTotal: 100000 * 1024,
  multipliers: [5, 2],
};

var RECEIVE_PARAMETER = {
  numSockets: 1,
  startSize: 10 * 1024,
  stopThreshold: 100000 * 1024,
  minTotal: 100000 * 1024,
  multipliers: [5, 2],
};

var sockets = [];
var numEstablishedSockets = 0;

var addressBox = null;

var timerID = null;

benchmark.startTimeInMs = 0;

var totalSize = 0;
var totalReplied = 0;

function destroySocket(socket) {
  socket.onopen = function() {};
  socket.onmessage = function() {};
  socket.onerror = function() {};
  socket.onclose = function() {};
  socket.close();
}

function destroyAllSockets() {
  for (var i = 0; i < sockets.length; ++i) {
    destroySocket(sockets[i]);
  }
  sockets = [];
}

function sendBenchmarkStep(size, multiplierIndex, parameter, config) {
  if (size > parameter.stopThreshold) {
    addToLog('Finished');
    destroyAllSockets();
    return;
  }

  var onMessageHandler = function(event) {
    if (!verifyAcknowledgement(event.data, size)) {
      destroyAllSockets();
      return;
    }

    totalReplied += size;

    if (totalReplied < totalSize) {
      return;
    }

    calculateAndLogResult(
        size, benchmark.startTimeInMs, totalSize, config.printSize);

    timerID = setTimeout(
        sendBenchmarkStep,
        0,
        size * parameter.multipliers[multiplierIndex],
        (multiplierIndex + 1) % parameter.multipliers.length,
        parameter,
        config);
  };

  for (var i = 0; i < sockets.length; ++i) {
    var socket = sockets[i];
    socket.onmessage = onMessageHandler;
  }

  benchmark.startTimeInMs = getTimeStamp();

  totalReplied = 0;

  totalSize = 0;

  var socketIndex = 0;
  while (totalSize < parameter.minTotal) {
    var buffer = new ArrayBuffer(size);

    fillArrayBuffer(buffer, 0x61);

    var command = ['send'];
    command.push(config.verifyData ? '1' : '0');
    sockets[socketIndex].send(command.join(' '));
    sockets[socketIndex].send(buffer);
    socketIndex = (socketIndex + 1) % sockets.length;

    totalSize += size;
  }
}

function receiveBenchmarkStep(size, multiplierIndex, parameter, config) {
  if (size > parameter.stopThreshold) {
    addToLog('Finished');
{'fraction_non_alphanumeric': 0.09368244054768196, 'fraction_numerical': 0.01897669949555609, 'mean_word_length': 3.8356562137049943, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5365521', 'n_tokens_mistral': 2622, 'n_tokens_neox': 2348, 'n_words': 870}