提交 5ff129a9 编写于 作者: J Johannes Rieken

add uri perf test, #50800this calls toString and toJSON uris of all files in our src folder

上级 70d6a338
此差异已折叠。
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import URI from 'vs/base/common/uri';
import { readFileSync } from 'fs';
suite('URI - perf', function () {
let manyFileUris: URI[];
setup(function () {
manyFileUris = [];
let data = readFileSync(URI.parse(require.toUrl('./uri.test.data.txt')).fsPath).toString();
let lines = data.split('\n');
for (let line of lines) {
manyFileUris.push(URI.file(line));
}
});
function perfTest(name: string, callback: Function) {
test(name, _done => {
let t1 = Date.now();
callback();
let d = Date.now() - t1;
console.log(`${name} took ${d}ms (${(d / manyFileUris.length).toPrecision(3)} ms/uri)`);
_done();
});
}
perfTest('toString', function () {
for (const uri of manyFileUris) {
let data = uri.toString();
assert.ok(data);
}
});
perfTest('toString(skipEncoding)', function () {
for (const uri of manyFileUris) {
let data = uri.toString(true);
assert.ok(data);
}
});
perfTest('toJSON', function () {
for (const uri of manyFileUris) {
let data = uri.toJSON();
assert.ok(data);
}
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册