Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (let i = 0; i < size; i++) {
const hash = reader.slice(20).toString('hex')
hashes[i] = hash
}
log(`hashes ${marky.stop('hashes').duration}`)
reader.seek(reader.tell() + 4 * size)
// Skip over CRCs
marky.mark('offsets')
// Get offsets
const offsets = new Map()
for (let i = 0; i < size; i++) {
offsets.set(hashes[i], reader.readUInt32BE())
}
log(`offsets ${marky.stop('offsets').duration}`)
const packfileSha = reader.slice(20).toString('hex')
log(`fromIdx ${marky.stop('fromIdx').duration}`)
return new GitPackIndex({
hashes,
crcs: {},
offsets,
packfileSha,
getExternalRefDelta
})
}
function computeTransformsPartTwo(nationalId, outAnimation) {
marky.mark('computeTransformsPartTwo()');
// reeeaaally fling it away when animating out. looks better
var slideInY = outAnimation ? screenHeight * 1.1 : screenHeight * 0.6;
var fgTransform = `translateY(${slideInY}px)`;
marky.stop('computeTransformsPartTwo()');
return {
fgTransform
};
}
exports.endIteration = function (testCase) {
var entry = marky.stop(testCase.name);
results.tests[testCase.name].iterations.push(entry.duration);
};
this.failedChunks.splice(failedChunkIndex, 1);
}
let trytesMessage = this.iota.utils.toTrytes(JSON.stringify({[this.ChunkContentKey]: chunk["content"]}));
let address = await this.getNewIotaAddress();
let transaction = await this.sendTransaction(address, trytesMessage);
Marky.stop('saveToTangle');
chunk["hash"] = transaction["hash"];
chunk["persisted"] = true;
this.chunkBundle[chunk["index"]] = chunk;
this.successfulChunks += 1;
return true;
} catch (err) {
Marky.stop('saveToTangle');
if (this.failedChunks.indexOf(chunk["index"]) === -1) {
this.failedChunks.push(chunk["index"]);
}
console.warn(err.message, chunk);
}
}
async persistChunk(chunk) {
Marky.mark('saveToTangle');
try {
let failedChunkIndex = this.failedChunks.indexOf(chunk["index"]);
if (failedChunkIndex !== -1) {
this.failedChunks.splice(failedChunkIndex, 1);
}
let trytesMessage = this.iota.utils.toTrytes(JSON.stringify({[this.ChunkContentKey]: chunk["content"]}));
let address = await this.getNewIotaAddress();
let transaction = await this.sendTransaction(address, trytesMessage);
Marky.stop('saveToTangle');
chunk["hash"] = transaction["hash"];
chunk["persisted"] = true;
this.chunkBundle[chunk["index"]] = chunk;
this.successfulChunks += 1;
return true;
} catch (err) {
Marky.stop('saveToTangle');
if (this.failedChunks.indexOf(chunk["index"]) === -1) {
this.failedChunks.push(chunk["index"]);
}
console.warn(err.message, chunk);
}
}
descriptor.value = async function(this: void, ...args: any[]) {
if (ProfilingEnabled) {
mark(propertyKey)
}
let result = await functionToMeasure.apply(this, args)
if (ProfilingEnabled) {
let measurement = stop(propertyKey)
console.log(`method '${measurement.name}' took ${measurement.duration.toFixed(2)} ms`)
}
return result
}
}
function doApplyPatch(patchString) {
marky.mark('JSON.parse()');
var patch = JSON.parse(patchString);
marky.stop('JSON.parse()');
marky.mark('patchElement()');
applyPatch(monstersList, patch);
marky.stop('patchElement()');
progress.end();
}
const oid = await shasum(GitObject.wrap({ type, object }))
times.hash += marky.stop('hash').duration
o.oid = oid
hashes.push(oid)
offsets.set(oid, offset)
crcs[oid] = o.crc
} catch (err) {
log('ERROR', err)
continue
}
}
marky.mark('sort')
hashes.sort()
times['sort'] = Math.floor(marky.stop('sort').duration)
const totalElapsedTime = marky.stop('total').duration
times.hash = Math.floor(times.hash)
times.readSlice = Math.floor(times.readSlice)
times.misc = Math.floor(
Object.values(times).reduce((a, b) => a - b, totalElapsedTime)
)
log(Object.keys(times).join('\t'))
log(Object.values(times).join('\t'))
log('by depth:')
log([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].join('\t'))
log(objectsByDepth.slice(0, 12).join('\t'))
log(
timeByDepth
.map(Math.floor)
.slice(0, 12)
.join('\t')
)
var sourceSpriteRect = sourceSprite.getBoundingClientRect();
var detailSpriteRect = getDetailSpriteRect();
var sourceTitleSpanHeight = getSpanHeight(sourceTitleSpan);
var spriteChangeX = sourceSpriteRect.left - detailSpriteRect.left;
var spriteChangeY = sourceSpriteRect.top - detailSpriteRect.top;
var scaleX = sourceSpriteRect.width / screenWidth;
var scaleY = (sourceSpriteRect.height - sourceTitleSpanHeight) / screenHeight;
var toX = sourceSpriteRect.left;
var toY = sourceSpriteRect.top;
var bgTransform = `translate(${toX}px,${toY}px) scale(${scaleX},${scaleY})`;
var spriteTransform = `translate(${spriteChangeX}px, ${spriteChangeY}px)`;
marky.stop('computeTransformsPartOne()');
return {
bgTransform,
spriteTransform,
spriteTop: detailSpriteRect.top + getScrollTop(),
spriteLeft: detailSpriteRect.left
};
}
const measure = (name, fn) => {
marky.mark(name);
fn();
const performanceMeasure = marky.stop(name);
return performanceMeasure.duration;
};