Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var fakeSwitch = {
- test0: function() {},
- test1: function() {},
- test2: function() {},
- test3: function() {},
- test4: function() {}
- }
- function testFakeSwitch(item) {
- fakeSwitch[item]()
- }
- function testRealSwitch(item) {
- switch(item) {
- case 'test0':
- break
- case 'test1':
- break
- case 'test2':
- break
- case 'test3':
- break
- case 'test4':
- break
- }
- }
- // Test Real Switch
- setTimeout(function() {
- var timer = performance.now()
- for(var i = 0; i < 1000000; i++) {
- testRealSwitch('test4')
- }
- console.log('real: ' + (performance.now() - timer))
- }, 0)
- // Test Fake Switch
- setTimeout(function() {
- var timer = performance.now()
- for(var i = 0; i < 1000000; i++) {
- testFakeSwitch('test4')
- }
- console.log('fake: ' + (performance.now() - timer))
- }, 500)
Add Comment
Please, Sign In to add comment