This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arrX1 = [1,2,3, "", true, null, {}, 20, 40, 50, 60]; | |
var arrY1 = [4,5,6, {}, 123, Object, 43, ",", void 0, null]; | |
var arrX2 = [1,2,3, "", true, null, {}, 20, 40, 50, 60]; | |
var arrY2 = [4,5,6, 234, {}, {}, Object, 43, ",", void 0, null]; | |
var arrX3 = [1,2,3, {}, 20, 40, 50, 60]; | |
var arrY3 = [4,5,6]; | |
var arrX4 = [1,2,3, "", true, 23, null, {}]; | |
var arrY4 = [4,5,6, false]; | |
var arrX5 = [1,2,3, 123, "", true, null, {}, 20]; | |
var arrY5 = [4,5,6, false, "", {}, Object]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// results: new P, new P ~160ms | |
// results: new P, new PP ~190ms | |
// results: new PP, new PP ~210ms | |
function P() { | |
} | |
P.prototype.then = function (fn, arg) { | |
fn(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var js = fs.readFileSync('small.js', 'utf-8'); | |
// performance: | |
// 10mb of code - 50ms | |
function find(js) { | |
var skipBlocks = []; | |
var k = 0; | |
js = js + '\n'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Utf8 parse performance: 1000 * 140kb ~ 140mb | |
// UTF8ToUTF16: 520ms | |
// Buffer.toString: 510ms | |
// Convert utf16 to utf8 performance: 1000 * 125k length | |
// UTF16ToUTF8: 420ms | |
// Buffer.toString: 1000ms | |
function UTF8ToUTF16(arr) { | |
var arrBuff = new ArrayBuffer(arr.length * 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//results | |
//1000 massive nodes with 32 subnodes, a lot of attributes | |
//deepclone: 50ms | |
//createFromJSOjb: 150ms | |
function createNodes() { | |
var div = document.createElement('div'); | |
div.innerHTML = '<div class=" thing id-t3_5fwc30 odd gilded link " id="thing_t3_5fwc30" data-fullname="t3_5fwc30" data-type="link" data-author="Hawke45" data-author-fullname="t2_bnjaz" data-subreddit="pics" data-subreddit-fullname="t5_2qh0u" data-timestamp="1480595816000" data-url="https://i.reddituploads.com/b45b1452a8414f38a0b498007e5bcd3f?fit=max&h=1536&w=1536&s=cd98d1163f90c23f1f5ec11083507bb8" data-domain="i.reddituploads.com" data-rank="1" data-context="listing">' + | |
'<p class="parent"></p><span class="rank">1</span><div class="midcol unvoted"><div class="arrow up login-required access-required" data-event-action="upvote" role="button" aria-label="Голосовать «за»" tabindex="0"></div><div class="score dislikes">10391</div><div class="score unvoted">10392</div><div class="score likes">10393</div><div c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface RouteProps { | |
search: {}; | |
urlParams: {}; | |
} | |
interface Data{ | |
a: number; | |
} | |
interface AppProps extends RouteProps { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const fs = require('fs'); | |
console.log(process.argv); | |
const version = 4; | |
const file = process.argv[2]; | |
const data = fs.readFileSync(file); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Utf8BufferToUint16Array(buff) { | |
let c, char2, char3; | |
let len = buff.length; | |
let i = 0; | |
let ni = 0; | |
const newA = new Uint16Array(len); | |
while (i < len) { | |
c = buff[i++]; | |
if (c < 128) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//results for 10 items array/hash | |
// 3,6,8,10ms/1m - binary search | |
// 15ms/1m - array fullscan | |
// 10ms/1m - hash fullscan | |
// 2ms/1m - hash found | |
function abc(fn, title, count, arg, arg2) { | |
console.time(title); | |
var result; | |
var i = count; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function abc(fn, iter, arg) { | |
var name = getName(fn); | |
console.time(name); | |
for (var i = 0; i < iter; i++) { | |
fn(arg); | |
} | |
console.timeEnd(name); | |
} | |
function getName(fn) { |