Run 5 times, with one second delay between calls
t1 = new Timer(500, function(){
console.log(this.count);
if (this.count >= 5) {
this.stop();
}
});
| function unicodeToActualCharacter(code) { | |
| // Convert unicode sequence to actual character | |
| // | |
| // unicodeToActualCharacter('U+005A') --> "Z" | |
| return eval('"'+ code.replace("U+", "\\u") +'"'); | |
| } |
| <script> | |
| KeyboardEvent.prototype.__defineGetter__('character', function(){ | |
| return (this.ctrlKey || this.altKey || this.metaKey || !this.charCode) | |
| ? "" | |
| : String.fromCharCode(this.charCode); | |
| }); | |
| onkeypress = function(e){ | |
| document.getElementById('char').innerHTML += e.character + ' ' | |
| } |
| // Better function.bind() | |
| // Origin http://twitpic.com/1tbwip | |
| // Inspired by http://perfectionkills.com/semantic-constructors/ | |
| Function.prototype.bind = function bind(thisObject) { | |
| var func = this; | |
| var args = Array.prototype.slice.call(arguments, 1); | |
| function bound() { | |
| return func.apply(thisObject, args.concat(Array.prototype.slice.call(arguments, 0))); | |
| } | |
| bound.toString = function toString() { |
| <html> | |
| <head> | |
| <title>modify text bench</title> | |
| </head> | |
| <body> | |
| <table> | |
| <tr> | |
| <td>div.appendChild(document.createTextNode( text ))</td> | |
| <td id="text_node"></td> |
| WebKit$ WebKitTools/Scripts/run-webkit-tests | |
| Running build-dumprendertree | |
| === BUILDING NATIVE TARGET DumpRenderTree OF PROJECT DumpRenderTree WITH CONFIGURATION Release === | |
| Checking Dependencies... | |
| CompileC /Users/nikitavasilev/Code/WebKit/WebKitBuild/DumpRenderTree.build/Release/DumpRenderTree.build/Objects-normal/i386/AccessibilityController.o /Users/nikitavasilev/Code/WebKit/WebKitTools/DumpRenderTree/AccessibilityController.cpp normal i386 c++ com.apple.compilers.gcc.4_2 | |
| cd /Users/nikitavasilev/Code/WebKit/WebKitTools/DumpRenderTree | |
| /Developer/usr/bin/gcc-4.2 -x c++ -arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -Os -mdynamic-no-pic -Werror -Wunused-function -Wunused-variable -DENABLE_DASHBOARD_SUPPORT -DWEBKIT_VERSION_MIN_REQUIRED=WEBKIT_VERSION_LATEST -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated-declarations -mmacosx-version-min=10.5 -gdwarf-2 -I/Users/nikitavasilev/Code/WebKit/WebKitBuild/DumpRenderTree.build/Release/DumpRenderTree.build/Dump |
| const ITERATIONS = 100000; | |
| (function(){ | |
| var start = new Date; | |
| for (var i=0; i<ITERATIONS; ++i) { | |
| Math.floor((i + ITERATIONS) / 2); | |
| } | |
| var end = new Date; | |
| print("Math.floor: "+ (end - start) +"ms"); | |
| })(); |
| var TOTAL = 3000; | |
| // Prepare test data | |
| var b = []; | |
| for (var i=0; i<TOTAL; ++i) { | |
| b[i] = [i]; | |
| } | |
| (function(){ |
| puts "Hello World!" |
| (function(){ | |
| print("Hello World!"); | |
| })(); |