Console Timer
A better timer for the console.
I wanted a simple referential timer that I could use that works the same way in all systems. The native console timer functions can be buggy in Chrome and other systems don't even all support it such as older versions of iOS.
However it is useful to have a timer on the global console
object and not have to require it into your environment when testing performance.
Usage
;; console;;console; // foo(203ms)
Bound finish function
;; const finish = consoletime;;; // foo(203ms)
Name collisions
You can pass in a method map to override the method names if you are worried about collision.
;; console;;console; // foo(203ms)
Customize your colors
You can pass a colors object to the options when setting up console-timer for multicoloured ANSI terminals
;
Use objects as references
You can use (mutable) objects as timer keys.
console;;console; // foo(203ms)
Don't use console if you don't want to
You can use another context if you don't want monkey patched methods on console
; let myobj = {}; ; myobj;;myobj; // foo(203ms)
Multiple starts
Starting a timer multiple times will simply interrupt timer and restart
;; console;console; // foo(0ms) - INTERRUPTED!;console; // foo(203ms)