<commit_before><!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>lua.vm.js</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le styles -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <style>
      body {
        padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
      }
    </style>
    <link href="css/bootstrap-responsive.css" rel="stylesheet">

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
    <![endif]-->
  </head>

  <body>

    <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="brand" href="#">lua.vm.js</a>
          <div class="nav-collapse collapse">
            <ul class="nav">
              <li class="active"><a href="#">Home</a></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>

    <div class="container">

      <div class="hero-unit">
        <h1>The Lua VM, on the Web</h1>
        <p>This is an experiment in running <a href="http://www.lua.org/">Lua</a> on the web, by porting the Lua C implementation using <a href="http://emscripten.org">Emscripten</a>. The motivation is that porting the standard VM is the best way to get the full, correct Lua language. It's also a fast register-based VM.</p>
        <h4>Are you really porting the entire Lua VM?</h4>
        <p>Yes. Porting the VM means we are running an entire VM - including GC - inside your JavaScript VM.
           That might sound worrying, but turns out the compiled Lua VM is only 200K (gzipped), and it can start up and run pretty quickly, XXXDATAXXX.</p>
        <br>
        <p><a href="#" class="btn btn-primary btn-large " onclick="run(); return false" id="the_button">Measure how fast your browser can run a VM in a VM &raquo;</a></p>
      </div>

      <div class="row-fluid">
        <div class="span">
          <h3>Individual Benchmark results</h3>
            <table class="table table-striped table-bordered table-hover">
              <thead>
                <tr>
                  <th>Benchmark</th>
                  <th>Result</th>
                  <th>Scale</th>
                  <th>Description</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td>binarytrees</td>
                  <td id="binarytrees-output"></td>
                  <td>seconds (lower numbers are better)</td>
                  <td>measures GC performance</td>
                </tr>
                <tr>
                  <td>scimark</td>
                  <td id="scimark-output"></td>
                  <td>MFLOPS (higher numbers are better)</td>
                  <td>measures numeric computation performance</td>
                </tr>
              </tbody>
            </table>
        </div>
      </div>

      <div class="row-fluid">
        <div class="span">
          <h3>Notes</h3>
          <p>For comparison, you can grab <a href="http://www.lua.org/download.html">Lua 5.2.2</a> (the version compiled here to JavaScript), build it natively, and run the same benchmarks (<a href="binarytrees.lua">binarytrees</a>, <a href="scimark.lua">scimark</a>). To run them, execute <code>lua scimark.lua</code> and <code>lua binarytrees.lua 14.72</code> (don't forget the second argument in binarytrees).</p>
          <p>To reproduce the JavaScript results, see how the Lua VM is built in the Emscripten benchmark suite, for example by <code>python tests/runner.py benchmark.test_lua_scimark</code>.</p>
        </div>
      </div>

    </div> <!-- /container -->

    <script>
var ran = false;
function run() {
  if (ran) return;
  ran = true;

  var theButton = document.getElementById('the_button');
  theButton.innerHTML = 'Running benchmarks...';
  theButton.classList.remove('btn-primary');
  theButton.classList.add('btn-warning');

  var benchmarks = {
    binarytrees: {
      args: ['binarytrees.lua', '14.72'],
      calculate: function(msg) {
        return msg.time/1000;
      }
    },
    scimark: {
      args: ['scimark.lua'],
      calculate: function(msg) {
        return /\nSciMark +([\d\.]+)/.exec(msg.output)[1]; 
      }
    }
  };

  function finalCalculation() {
    // normalize based on experimental data
    return 100*(20.308/benchmarks.binarytrees.result + benchmarks.scimark.result/3.19).toFixed(2);
  }

  var jobs = [];
  for (var b in benchmarks) {
    jobs.push(b);
  }
  var curr = 0;
  function runJob() {
    var job = jobs[curr++];
    if (!job) {
      theButton.innerHTML = 'Score: <strong>' + finalCalculation() + '</strong> (higher numbers are better)';
      theButton.classList.remove('btn-warning');
      theButton.classList.add('btn-success');
      return;
    }
    var worker = new Worker('benchmark-worker.js');
    worker.onmessage = function(event) {
      var msg = event.data;
      console.log(JSON.stringify(msg));
      if (msg.benchmark != job) throw 'invalid data from benchmark worker';
      benchmarks[job].result = benchmarks[job].calculate(msg);
      document.getElementById(job + '-output').innerHTML = '<b>' + benchmarks[job].result + '</b>';
      runJob();
    };<commit_msg>simplify output<commit_after><!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>lua.vm.js</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le styles -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <style>
      body {
        padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
      }
    </style>
    <link href="css/bootstrap-responsive.css" rel="stylesheet">

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
    <![endif]-->
  </head>

  <body>

    <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="brand" href="#">lua.vm.js</a>
          <div class="nav-collapse collapse">
            <ul class="nav">
              <li class="active"><a href="#">Home</a></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>

    <div class="container">

      <div class="hero-unit">
        <h1>The Lua VM, on the Web</h1>
        <p>This is an experiment in running <a href="http://www.lua.org/">Lua</a> on the web, by porting the Lua C implementation using <a href="http://emscripten.org">Emscripten</a>. The motivation is that porting the standard VM is the best way to get the full, correct Lua language. It's also a fast register-based VM.</p>
        <h4>Are you really porting the entire Lua VM?</h4>
        <p>Yes. Porting the VM means we are running an entire VM - including GC - inside your JavaScript VM.
           That might sound worrying, but turns out the compiled Lua VM is only 200K (gzipped), and it can start up and run pretty quickly, XXXDATAXXX.</p>
        <br>
        <p><a href="#" class="btn btn-primary btn-large " onclick="run(); return false" id="the_button">Measure how fast your browser can run a VM in a VM &raquo;</a></p>
      </div>

      <div class="row-fluid">
        <div class="span">
          <h3>Individual Benchmark results</h3>
            <table class="table table-striped table-bordered table-hover">
              <thead>
                <tr>
                  <th>Benchmark</th>
                  <th>Result</th>
                  <th>Scale</th>
                  <th>Description</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td>binarytrees</td>
                  <td id="binarytrees-output"></td>
                  <td>seconds (lower numbers are better)</td>
                  <td>measures GC performance</td>
                </tr>
                <tr>
                  <td>scimark</td>
                  <td id="scimark-output"></td>
                  <td>MFLOPS (higher numbers are better)</td>
                  <td>measures numeric computation performance</td>
                </tr>
              </tbody>
            </table>
        </div>
      </div>

      <div class="row-fluid">
        <div class="span">
          <h3>Notes</h3>
          <p>For comparison, you can grab <a href="http://www.lua.org/download.html">Lua 5.2.2</a> (the version compiled here to JavaScript), build it natively, and run the same benchmarks (<a href="binarytrees.lua">binarytrees</a>, <a href="scimark.lua">scimark</a>). To run them, execute <code>lua scimark.lua</code> and <code>lua binarytrees.lua 14.72</code> (don't forget the second argument in binarytrees).</p>
          <p>To reproduce the JavaScript results, see how the Lua VM is built in the Emscripten benchmark suite, for example by <code>python tests/runner.py benchmark.test_lua_scimark</code>.</p>
        </div>
      </div>

    </div> <!-- /container -->

    <script>
var ran = false;
function run() {
  if (ran) return;
  ran = true;

  var theButton = document.getElementById('the_button');
  theButton.innerHTML = 'Running benchmarks...';
  theButton.classList.remove('btn-primary');
  theButton.classList.add('btn-warning');

  var benchmarks = {
    binarytrees: {
      args: ['binarytrees.lua', '14.72'],
      calculate: function(msg) {
        return msg.time/1000;
      }
    },
    scimark: {
      args: ['scimark.lua'],
      calculate: function(msg) {
        return /\nSciMark +([\d\.]+)/.exec(msg.output)[1]; 
      }
    }
  };

  function finalCalculation() {
    // normalize based on experimental data
    return Math.round(100*(20.308/benchmarks.binarytrees.result + benchmarks.scimark.result/3.19));
  }

  var jobs = [];
  for (var b in benchmarks) {
    jobs.push(b);
  }
  var curr = 0;
  function runJob() {
    var job = jobs[curr++];
    if (!job) {
      theButton.innerHTML = 'Score: <strong>' + finalCalculation() + '</strong> (higher numbers are better)';
      theButton.classList.remove('btn-warning');
      theButton.classList.add('btn-success');
      return;
    }
    var worker = new Worker('benchmark-worker.js');
    worker.onmessage = function(event) {
      var msg = event.data;
      console.log(JSON.stringify(msg));
      if (msg.benchmark != job) throw 'invalid data from benchmark worker';
      benchmarks[job].result = benchmarks[job].calculate(msg);
      document.getElementById(job + '-output').innerHTML = '<b>' + benchmarks[job].result + '</b>';
      runJob();
    };
{'fraction_non_alphanumeric': 0.15640686922060767, 'fraction_numerical': 0.009247027741083224, 'mean_word_length': 2.229806598407281, 'pattern_counts': {'":': 0, '<': 277, '<?xml version=': 0, '>': 277, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2294691', 'n_tokens_mistral': 3606, 'n_tokens_neox': 3387, 'n_words': 919}