App-Cheats
view release on metacpan or search on metacpan
for(let i = 1; i <= iterations; i++ )
code();
console.timeEnd(name);
}
}
# Usage
benchmark([get_head_checkbox, get_head_checkbox2]);
benchmark([get_head_checkbox, get_head_checkbox2],10000);
# Function for benchmarking different code snippets (timing,testing,profiling)
# Includes percentages and sorted.
// function benchmark() {
// // Get inputs
// let code_refs = [...arguments];
// let iterations = 1;
// const last_index = code_refs.length - 1;
//
// // Check last input
// if(typeof(code_refs[last_index]) == "number")
// iterations = code_refs.pop();
//
// const time = (performance.now()-t0).toFixed(2);
// stats.push({name: _get_code_name(code), time: time});
// }
//
// // Sort statistics: fastest (lowest time) first
// stats.sort((a,b) => (Number(a.time) >= Number(b.time)) ? 1 : -1);
//
// // Baseline to compare with
// const longest_time = stats[stats.length-1]["time"];
//
// // Add percentage to each test set
// for(const set of stats){
// const time = set.time;
// const percent = ((longest_time-time)/time*100).toFixed(0);
// set.percent = percent;
// }
//
// // Print statistics
// console.table(stats);
// }
//
# Javascript function to convert a block of code to a name
// function _get_code_name(code) {
// const name = code.name; // Code reference to name
// let toString = code.toString(); // Code reference to name
# Undo last change (Vim)
u
# Undo all changes to line (Vim)
U
# Redo last command (Vim)
<Control> + r
# Diplay file name, number of lines (and percent) (Vim)
<Control> + g
# Type a control character in Vim
Control-V <RET>
# Convert binary to hex (Vim)
:%!xxd
# Comment a block of lines (Vim)
<Control> + v
( run in 0.420 second using v1.01-cache-2.11-cpan-709fd43a63f )