Results 1 to 2 of 2

Thread: [JS] Clocker

  1. #1
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default [JS] Clocker

    1) CODE TITLE: Clocker

    2) AUTHOR NAME/NOTES: Thomas Eding

    3) DESCRIPTION: Clocks and analyzes function speeds.

    4) URL TO CODE: http://trinithis.awardspace.com/Clocker/Clocker.js

    Use for analyzing speeds during development:
    Code:
    function a(){...}
    function b(){...}
    
    Clocker.time(a, 100);  //100 iterations of a
    Clocker.time(b, 100);  //100 iterations of b
    
    alert(Clocker.analyze());  //returns fastest trial(s) based on ms/iter
    Clocker.reset();  //clears the trial set
    
    Clocker.run(a, 100);  //run a for at least 100ms
    Clocker.run(b, 100);  //run b for at least 100ms
    
    alert(Clocker.analyze());  //returns fastest trial(s) based on ms/iter
    The code is smart enough to ignore the code stall of alert(), confirm(), and prompt() that might be in the tested functions. You can also name each trial by adding an extra argument to time() or run(). By default, the trials are named '1', '2', etc.

    NOTE: You should not use a Clocker.run() and a Clocker.time() in the same trial set because their algorithm times differ. If it is necessay, try using: http://trinithis.awardspace.com/Clocker/Clocker2.js or http://trinithis.awardspace.com/Clocker/Clocker3.js.
    Last edited by Trinithis; 09-15-2007 at 10:32 PM.
    Trinithis

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Again impressive. I have a very basic implementation of this already (I suspect all serious developers have), but it's not as featureful as this one.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •