debuk
Debug and performance test your code with a minimum setup
How to Install
Node
$ npm install --save-dev debuk
in the code
;var Debuk = ;
Browser(UMD)
This can be directly included into client side without any dependencies via
<!--- latest version ---><script src='https://unpkg.com/debuk/dist/debuk.js'><!--- minified version ---><script src='https://unpkg.com/debuk/dist/debuk.min.js'> <!--- a specific version ---><script src='https://unpkg.com/debuk@1.0.0/dist/debuk.js'> <script>var Debuk = debuk.default;</script>
you can also download source from the Releases
Browser
If you are using any dependency management system like webpack or browserify, you can use the Node import
Usage
Debuk is a wrapper to any function or class. You can simply wrap any function or
class with Debuk
and you can use it to check different runtime behaviours of that
function and class.
const myFun = {// implementation} // Wrap the method with Debukconst myFun = ; {} // Wrap class with Debukconst DebukClass = ;const myClass = ;
Simple example (Number of method calls)
var { return a + b;}; var list = 123456;list ;
Can you guess the number of mySum calls in the the above code and the parameters each were called with? Change the code above to wrap mySum with Debuk as below and you can view them on your browser console alone with the time it took to execute each function.
var mySum = ;
//Console outputmySum: 0.182msmySum params 1,5 => 6mySum: 0.103msmySum params 2,5 => 7mySum: 0.076msmySum params 3,5 => 8mySum: 0.076msmySum params 4,5 => 9mySum: 0.075msmySum params 5,5 => 10mySum: 0.073msmySum params 6,5 => 11mySum: 0.074msmySum params 7,5 => 12mySum: 0.076msmySum params 8,12 => 20mySum: 0.070msmySum params 8,5 => 13mySum: 0.073msmySum params 22,13 => 35mySum: 0.077msmySum params 9,5 => 14mySum: 0.072msmySum params 37,14 => 51mySum: 0.073msmySum params 10,5 => 15mySum: 0.071msmySum params 53,15 => 68mySum: 0.074msmySum params 11,5 => 16mySum: 0.075msmySum params 70,16 => 86mySum count: 16
Check JSBin
Console.count does the samething
Well in case you didnt know you can use console.count
to do the samething. But
what is more about Debuk is that it does the count per execution cycle not
global. So it will show how many times the method was used for that execution
cycle. In most of the cases you want to check what happens when on a particular
state. (When the user clicks on this button how many times this method was
called). Debuk is ideal for that.
API
fn
function to be wrapped
options
options to debuk. defaults are
name: 'Anonymous' params: false time: true trace: false profile: false promise: true count: true
bindThis
bind this
to fn
or not. Default false
Contributions
- We use sementic versioning and each build will trigger a version based on the commit message.
- 100% test coverage.
Roadmap
- Functions returning promises
- Add ES6 Decorator support
- Add support for ES6 Classes
- Performance statistics calculation (Mean / SD / Average)
License
MIT © 2016
`