Skip to content

Instantly share code, notes, and snippets.

@gyandeeps
Created April 18, 2016 14:38
Show Gist options
  • Save gyandeeps/54b00e50587ef42478db97b91a88c632 to your computer and use it in GitHub Desktop.
Save gyandeeps/54b00e50587ef42478db97b91a88c632 to your computer and use it in GitHub Desktop.
mithril-test.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="./node_modules/mithril/mithril.js"></script>
<title>JS Bin</title>
</head>
<body>
<div id = "main"></div>
<script>
;(function( console ) {
'use strict';
var timers;
// do we have access to the console?
if ( !console ) {
return;
}
// table of current timers
timers = {};
/**
* Stores current time in milliseconds
* in the timers map
*
* @param {string} timer name
* @return {void}
*/
console.time = function( name ) {
if ( name ) {
timers[ name ] = Date.now();
}
};
/**
* Finds difference between when this method
* was called and when the respective time method
* was called, then logs out the difference
* and deletes the original record
*
* @param {string} timer name
* @return {void}
*/
console.timeEnd = function( name ) {
if ( timers[ name ] ) {
console.log( name + ': ' + (Date.now() - timers[ name ]) + 'ms' );
delete timers[ name ];
}
};
}( window.console ));
var elem = document.getElementById("main");
function getCells(){
var data = [];
for(var i = 0; i < 3; i++){
data.push(m("div", {class: "cell"}, "cell" + i));
}
return data;
}
function getRows(){
var data = [];
for(var i = 0; i < 1000; i++){
data.push(m("div", {class: "row"}, getCells()));
}
return data;
}
var rows = m("div", {class: "rows"}, getRows());
console.time("test1");
m.render(elem, m("div", rows));
console.timeEnd("test1");
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment