Skip to content

Instantly share code, notes, and snippets.

@leplatrem
Created January 22, 2016 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leplatrem/3145f6b59a483aaf8a39 to your computer and use it in GitHub Desktop.
Save leplatrem/3145f6b59a483aaf8a39 to your computer and use it in GitHub Desktop.
benchmark kinto
<!DOCTYPE html>
<html>
<head>
<script src="kinto-dev.js"></script>
</head>
<body>
<h1>Benchmark</h1>
<p><span id="count">?</span> records in <span id="time">?</span> sec.
<button id="run">Run</button>
<button id="clear">Clear</button>
<script type="text/javascript">
var db = new Kinto({remote: "http://kinto-leplatrem.herokuapp.com/v1", bucket: "guessign", dbPrefix: "guessign"});
var collection = db.collection("fr");
var btn = document.getElementById("run");
btn.onclick = function () {
var before = new Date().getTime();
collection.sync()
.then(function (result) {
var after = new Date().getTime();
var elapsed = after - before;
document.getElementById("count").innerHTML = result.created.length + result.updated.length;
document.getElementById("time").innerHTML = elapsed / 1000;
});
}
var btn = document.getElementById("clear");
btn.onclick = function () {
collection.clear();
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment