<commit_before><!DOCTYPE HTML>
<html>
	<head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Testing $.proxy performances.</title>
            <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
            <script src="./js/mesure-kit.js"></script>
	</head>

<body>

    <section class="container">
        
        <h1>Proxy compared to inline closures</h1>
        <p>Simple test for proxy performances in jQuery.</p>

        <div class="panel panel-default">
            <div class="panel-body">
                <button class="btn btn-primary" onclick="runAll()">Run all</button>
                <button class="btn btn-warning" onclick="runBench()">Run a bench</button>
            </div>
        </div>

    </section>
    
    <section class="container">
        <h2>Tests</h2>
        
        <table class="table">
            <tbody>
                <tr>
                    <th>Direct call </th>
                    <td>Duration: <span id="valueDirect"></span></td>
                    <td><button class="btn btn-xs btn-primary" onclick="runDirect()">Run</button></td>
                </tr>

                <tr>
                    <th>Inline $.proxy()</th>
                    <td>Duration: <span id="valueProxy"></span></td>
                    <td><button class="btn btn-xs btn-primary" onclick="runProxy()">Run</button></td>
                </tr>

                <tr>
                    <th>Cached $.proxy()</th>
                    <td>Duration: <span id="valueProxy2"></span></td>
                    <td><button class="btn btn-xs btn-primary" onclick="runProxy2()">Run</button></td>
                </tr>

                <tr>
                    <th>Wrapper function</th>
                    <td>Duration: <span id="valueFn"></span></td>
                    <td><button class="btn btn-xs btn-primary" onclick="runFn()">Run</button></td>
                </tr>
            </tbody>
        </table>
    </section>


    <section class="container">
        <h2>Summary</h2>
        
        <section id="summary"></section>

    </section>

</body>

<script>

/** Simple point object.
 * 
 * @returns {Point}
 */
function Point() {
  this.x = 0.0;
  this.y = 0.0;
}

/** Compute distance with another point.
 * 
 * @param {Point} otherPoint
 * @returns {float}
 */
Point.prototype.dist = function(otherPoint) {
  var dX = (this.x - otherPoint.x);
  var dY = (this.y - otherPoint.y);
  
  d = Math.sqrt((dX * dX) + (dY * dY));
  
  return d;
};

// TESTS

var p1 = new Point(0, 0);
var p2 = new Point(3, 12);

var bench = new Bench({ nbLoop: 10000, summaryId: "summary" });

var proxyFn = $.proxy(p1.dist, p1);

bench.addTest('valueDirect', function() { 
    p1.dist(p2); 
});

bench.addTest('valueProxy', function() { 
    $.proxy(p1.dist, p1)(p2); 
});

bench.addTest('valueProxy2', function() { 
    proxyFn(p2); 
});

var pt = p1; // Capture p1
bench.addTest('valueFn', function() { 
    pt.dist(p2);
});

function runAll() { 
    bench.runAllTests(); 
    bench.insertSummaryTable();
};

function runBench() { 
    bench.runBench(50);
    bench.insertSummaryTable();
};

function runDirect() { bench.runTest("valueDirect"); };

function runProxy()  { bench.runTest("valueProxy"); };

function runProxy2() { bench.runTest("valueProxy2"); };

function runFn()     { bench.runTest("valueFn"); };


</script>

</html><commit_msg>Clafified ids and description<commit_after><!DOCTYPE HTML>
<html>
	<head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Testing $.proxy performances.</title>
            <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
            <script src="./js/mesure-kit.js"></script>
	</head>

<body>

    <section class="container">
        
        <h1>Proxy compared to inline closures</h1>
        <p>Simple test for proxy performances in jQuery.</p>

        <div class="panel panel-default">
            <div class="panel-body">
                <button class="btn btn-primary" onclick="runAll()">Run all</button>
                <button class="btn btn-warning" onclick="runBench()">Run a bench</button>
            </div>
        </div>

    </section>
    
    <section class="container">
        <h2>Tests</h2>
        
        <table class="table">
            <tbody>
                <tr>
                    <th>Direct call in closure</th>
                    <td>Duration: <span id="closure-direct"></span></td>
                    <td><button class="btn btn-xs btn-primary" onclick="runDirect()">Run</button></td>
                </tr>

                <tr>
                    <th>Closure with captured indirect reference</th>
                    <td>Duration: <span id="closure-with-capture"></span></td>
                    <td><button class="btn btn-xs btn-primary" onclick="runFn()">Run</button></td>
                </tr>
                <tr>
                    <th>Inline $.proxy()</th>
                    <td>Duration: <span id="proxy-inlined"></span></td>
                    <td><button class="btn btn-xs btn-primary" onclick="runProxy()">Run</button></td>
                </tr>

                <tr>
                    <th>Cached $.proxy()</th>
                    <td>Duration: <span id="proxy-cached"></span></td>
                    <td><button class="btn btn-xs btn-primary" onclick="runProxy2()">Run</button></td>
                </tr>

                <tr>
                    <th>Wrapper function</th>
                    <td>Duration: <span id="valueFn"></span></td>
                    <td><button class="btn btn-xs btn-primary" onclick="runFn()">Run</button></td>
                </tr>
            </tbody>
        </table>
    </section>


    <section class="container">
        <h2>Summary</h2>
        
        <section id="summary"></section>

    </section>

</body>

<script>

/** Simple point object.
 * 
 * @returns {Point}
 */
function Point() {
  this.x = 0.0;
  this.y = 0.0;
}

/** Compute distance with another point.
 * 
 * @param {Point} otherPoint
 * @returns {float}
 */
Point.prototype.dist = function(otherPoint) {
  var dX = (this.x - otherPoint.x);
  var dY = (this.y - otherPoint.y);
  
  d = Math.sqrt((dX * dX) + (dY * dY));
  
  return d;
};

// TESTS

var p1 = new Point(0, 0);
var p2 = new Point(3, 12);

var bench = new Bench({ nbLoop: 20000, summaryId: "summary" });

var proxyFn = $.proxy(p1.dist, p1);

bench.addTest('closure-direct', function() { 
    p1.dist(p2); 
});

var pt = p1; // Capture p1
bench.addTest('closure-with-capture', function() { 
    pt.dist(p2);
});

bench.addTest('proxy-inlined', function() { 
    $.proxy(p1.dist, p1)(p2); 
});

var proxyFn = $.proxy(p1.dist, p1);
bench.addTest('proxy-cached', function() { 
    proxyFn(p2); 
});

var pt = p1; // Capture p1
bench.addTest('valueFn', function() { 
    pt.dist(p2);
});

function runAll() { 
    bench.runAllTests(); 
    bench.insertSummaryTable();
};

function runBench() { 
    bench.runBench(50);
    bench.insertSummaryTable();
};

function runDirect() { bench.runTest("closure-direct"); };

function runFn()     { bench.runTest("closure-with-capture"); };

function runProxy()  { bench.runTest("proxy-inlined"); };

function runProxy2() { bench.runTest("proxy-cached"); };


</script>

</html>
{'fraction_non_alphanumeric': 0.18088386433710174, 'fraction_numerical': 0.013360739979445015, 'mean_word_length': 2.0941971383147853, 'pattern_counts': {'":': 0, '<': 203, '<?xml version=': 0, '>': 203, 'https://': 4, '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': '4353193', 'n_tokens_mistral': 2574, 'n_tokens_neox': 2426, 'n_words': 476}