当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript benchmark.Suite类代码示例

本文整理汇总了TypeScript中benchmark.Suite的典型用法代码示例。如果您正苦于以下问题:TypeScript Suite类的具体用法?TypeScript Suite怎么用?TypeScript Suite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Suite类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: benchmarkSudoku

function benchmarkSudoku () {
  console.log('Benchmark: A solution to the sodoku\n')
  const sudokuField = parseStringFormat(9, '..............3.85..1.2.......5.7.....4...1...9.......5......73..2.1........4...9')
  console.log(printBoard(9, sudokuField), '\n')

  // Picked from https://github.com/attractivechaos/plb/blob/master/sudoku/sudoku.txt
  const constraints = generateConstraints(9, sudokuField)
  const plainRows = constraints.map((c) => c.row)
  const searchConfig = getSearchConfig(Infinity, constraints)

  const suite = new Benchmark.Suite()

  suite.add('dancing-links find', function () {
    find(constraints, Infinity)
  }).add('dancing-links findRaw', function () {
    findRaw(searchConfig)
  }).add('dlxlib', function () {
    dlxlib.solve(plainRows)
  }).add('dance', function () {
    dance.solve(plainRows, {})
  }).add('dancing-links-algorithm', function () {
    dancingLinksAlgorithm.solve(plainRows)
  })
  .on('cycle', function (event) {
    console.log(String(event.target))
  })
  .on('complete', function () {
    console.log('Fastest is ' + this.filter('fastest').map('name') + '\n\n')
  }).run()
}
开发者ID:TimBeyer,项目名称:node-dlx,代码行数:30,代码来源:index.ts

示例2: benchmarkHundredTilings

function benchmarkHundredTilings () {
  console.log('Benchmark: Finding one hundred pentomino tilings on a 6x10 field\n')

  const dlxlibConstraints = ALL_CONSTRAINTS.map((constraint) => constraint.row)
  const searchConfig = getSearchConfig(100, ALL_CONSTRAINTS)

  const suite = new Benchmark.Suite()

  suite.add('dancing-links find', function () {
    find(ALL_CONSTRAINTS, 100)
  }).add('dancing-links findRaw', function () {
    findRaw(searchConfig)
  }).add('dlxlib', function () {
    dlxlib.solve(dlxlibConstraints, null, null, 100)
  }).add('dance', function () {
    dance.solve(dlxlibConstraints, {
      maxSolutions: 100
    })
  })
    .on('cycle', function (event) {
      console.log(String(event.target))
    })
    .on('complete', function () {
      console.log('\nFastest is ' + this.filter('fastest').map('name') + '\n\n')
    }).run()
}
开发者ID:TimBeyer,项目名称:node-dlx,代码行数:26,代码来源:index.ts

示例3: async

const addMany = (names: string[]): benchmark.Suite => {
	for (let name of names) {
		for (let file of files) {
			suite = suite.add(`${name} -> ${file}`, async () => {
				let rfs = await toBench.byName(name).rfs;
				rfs.require(file);
			});
		}
	}
	_start = performance.now();
	return suite;
}
开发者ID:AhmadAlyTanany,项目名称:code-server,代码行数:12,代码来源:requirefs.bench.ts

示例4: createLogger

import { c, createLogger } from '../../logger';
import * as Benchmark from 'benchmark';
import { dev, local } from './aurelia';

const args = process.argv.slice(2);
const name = args[0];
const rest = args.slice(1);
const log = createLogger('container');

const suites = {
  ['register']() {
    const suite = new Benchmark.Suite('register', {
      onCycle: function(event) {
        log(`[${c.cyan(name)}] ${event.target}`);
      }
    });

    suite.add(`local runtime-html BasicConfiguration`, function() {
      local.kernel.DI.createContainer().register(local.runtimeHtml.BasicConfiguration);
    });
    suite.add(`local jit-html     BasicConfiguration`, function() {
      local.kernel.DI.createContainer().register(local.jitHtml.BasicConfiguration);
    });

    suite.add(`  dev runtime-html BasicConfiguration`, function() {
      dev.kernel.DI.createContainer().register(dev.runtimeHtml.HTMLRuntimeConfiguration);
    });
    suite.add(`  dev jit-html     BasicConfiguration`, function() {
      dev.kernel.DI.createContainer().register(dev.jitHtml.HTMLJitConfiguration);
    });
开发者ID:aurelia,项目名称:aurelia,代码行数:30,代码来源:container.ts

示例5: Computer

import * as benchmark from "benchmark";
import {Computer} from "../Computer";

const suite = new benchmark.Suite("speed");

const fibProgram = [
    "LOAD 0 %A",
    "LOAD 1 %B",
    "LOAD 1 %C",
    "LOAD 0 %D",
    "loop:",
    "CMP " + 20 + " %D",
    "INC %D",
    "JMPLEQ $halt",
    "ADD %C %B %E",
    "LOAD %A %B",
    "LOAD %B %C",
    "LOAD %C %E",
    "JMP $loop",
    "halt:",
    "HALT",
].join("\n");

const computer = new Computer();
computer.loadProgram(fibProgram);

suite.add("fibonacci", () => {
    computer.cpu.registers.zeroOut();
    computer.cpu.runSynchronouslyUntilHalted();
});
开发者ID:ichub,项目名称:tinyassembly,代码行数:30,代码来源:SpeedBench.ts

示例6: require

import { Entity } from '../Entity';
import { FamilyMock } from '../test/Family.stub';
import { Engine } from '../Engine';
import { SystemMock, SystemMock2 } from '../test/System.stub';

const bench = require('benchmark');
const suite = new bench.Suite();

suite
    .add('AddEntityToEngine', function() {
        let engine = new Engine();
        engine.familyClass = FamilyMock;
        let entity1: Entity = new Entity();
        engine.addEntity(entity1);
        let entity2: Entity = new Entity();
        engine.addEntity(entity2);
    })
    .add('AddSystemToEngine', function() {
        let engine = new Engine();
        engine.familyClass = FamilyMock;
        let system1 = new SystemMock();
        engine.addSystem(system1, 10);
        let system2 = new SystemMock2();
        engine.addSystem(system2, 5);
    })
    .on('cycle', function(event) {
        console.log(String(event.target));
    })
    .on('complete', function() {
        console.log('Fastest is ' + this.filter('fastest').pluck('name'));
    })
开发者ID:Herndl,项目名称:silverback,代码行数:31,代码来源:Engine.ts

示例7: Computer

import * as benchmark from "benchmark";
import {Computer} from "../Computer";

const suite = new benchmark.Suite("program writing to graphics memory");

const graphicsProgram = [
    "LOAD 0 %A",
    "LOAD 0 %B",
    "LOAD 5 %C",
    "LOAD 3 %D",
    "LOAD #g_char_size %E",
    "MUL 33 %E",
    "ADD #m_static_low %E",
    "loop:",
    "CLS",
    "BLIT %E %A %B",
    "ADD %C %A %A",
    "ADD %D %B %B",
    "DRAW",
    "JMP $loop",
].join("\n");

const computer = new Computer();
computer.loadProgram(graphicsProgram);

suite.add("simple graphics", () => {
    computer.cpu.registers.zeroOut();
    computer.cpu.runSynchronouslyFor(20);
});

export = suite;
开发者ID:ichub,项目名称:tinyassembly,代码行数:31,代码来源:GraphicsSpeedBench.ts

示例8:

}).on("complete", () => {
	const slowest = suite.filter("slowest").shift();
	const fastest = suite.filter("fastest").shift();
	console.log(`===\nFastest is ${fastest.name} with ~${mean(fastest)} Îźs/op`);
	if (slowest.name !== fastest.name) {
		console.log(`Slowest is ${slowest.name} with ~${mean(slowest)} Îźs/op`);
	}
	const d = ((performance.now() - _start)/1000).toFixed(2);
	console.log(`Benchmark took ${d} s`);
})
开发者ID:AhmadAlyTanany,项目名称:code-server,代码行数:10,代码来源:requirefs.bench.ts

示例9: log

 Promise.all(groupPromises).then(() => {
   log('Running benchmarks.');
   bsuite
     .on('error', (error: any) => {
       log('Error: ', error);
     })
     .on('cycle', (event: any) => {
       log('Mean time in ms: ', event.target.stats.mean * 1000);
       log(String(event.target));
     })
     .run({ async: false });
 });
开发者ID:softden2006,项目名称:apollo-client,代码行数:12,代码来源:util.ts

示例10: benchmarkFn

      new Promise<void>((resolve, _) => {
        bsuite.add(name, {
          defer: true,
          fn: (deferred: any) => {
            const done = () => {
              cycleCount++;
              deferred.resolve();
            };

            benchmarkFn(done);
          },

          onComplete: (event: any) => {
            if (afterEachFn) {
              afterEachFn(description, event);
            }
            resolve();
          },
        });
      }),
开发者ID:softden2006,项目名称:apollo-client,代码行数:20,代码来源:util.ts


注:本文中的benchmark.Suite类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。