How to use filteredBenchmarks method in Best

Best JavaScript code snippet using best

index.js

Source:index.js Github

copy

Full Screen

1'use strict';2/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "BenchmarksView|clipboard" }]*/3var util = require('../js/util/util');4var mapboxgl = require('../js/mapbox-gl');5var Clipboard = require('clipboard');6var BenchmarksView = React.createClass({7 render: function() {8 return <div style={{width: 960, paddingBottom: window.innerHeight, margin: '0 auto'}}>9 {this.renderBenchmarkSummaries()}10 {this.renderBenchmarkDetails()}11 </div>;12 },13 renderBenchmarkSummaries: function() {14 return <div className='col4 prose' style={{paddingTop: 40, width: 320, position: 'fixed'}}>15 <h1 className="space-bottom">Benchmarks</h1>16 <div className="space-bottom">17 {Object.keys(this.state.results).map(this.renderBenchmarkSummary)}18 </div>19 <a20 className={[21 'icon',22 'clipboard',23 'button',24 (this.state.state === 'ended' ? '' : 'disabled')25 ].join(' ')}26 data-clipboard-text={this.renderBenchmarkTextSummaries()}>27 Copy Results28 </a>29 </div>;30 },31 renderBenchmarkSummary: function(name) {32 var results = this.state.results[name];33 var that = this;34 return <div35 onClick={function() {36 that.scrollToBenchmark(name);37 }}38 style={{cursor: 'pointer'}}39 key={name}40 className={[41 results.state === 'waiting' ? 'quiet' : ''42 ].join(' ')}>43 <strong>{name}:</strong> {results.message || '...'}44 </div>;45 },46 renderBenchmarkTextSummaries: function() {47 var output = '# Benchmarks\n\n';48 for (var name in this.state.results) {49 var result = this.state.results[name];50 output += '**' + name + ':** ' + (result.message || '...') + '\n';51 }52 return output;53 },54 renderBenchmarkDetails: function() {55 return <div style={{width: 640, marginLeft: 320, marginBottom: 60}}>56 {Object.keys(this.state.results).map(this.renderBenchmarkDetail)}57 </div>;58 },59 renderBenchmarkDetail: function(name) {60 var results = this.state.results[name];61 return (62 <div63 id={name}64 key={name}65 style={{paddingTop: 40}}66 className={results.state === 'waiting' ? 'quiet' : ''}>67 <h2 className='space-bottom'>"{name}" Benchmark</h2>68 {results.logs.map(function(log, index) {69 return <div key={index} className={'pad1 dark fill-' + log.color}>{log.message}</div>;70 })}71 </div>72 );73 },74 scrollToBenchmark: function(name) {75 var duration = 300;76 var startTime = (new Date()).getTime();77 var startYOffset = window.pageYOffset;78 requestAnimationFrame(function frame() {79 var endYOffset = document.getElementById(name).offsetTop;80 var time = (new Date()).getTime();81 var yOffset = Math.min((time - startTime) / duration, 1) * (endYOffset - startYOffset) + startYOffset;82 window.scrollTo(0, yOffset);83 if (time < startTime + duration) requestAnimationFrame(frame);84 });85 },86 getInitialState: function() {87 return {88 state: 'waiting',89 runningBenchmark: Object.keys(this.props.benchmarks)[0],90 results: util.mapObject(this.props.benchmarks, function(_, name) {91 return {92 name: name,93 state: 'waiting',94 logs: []95 };96 })97 };98 },99 componentDidMount: function() {100 var that = this;101 var benchmarks = Object.keys(that.props.benchmarks);102 setTimeout(function next() {103 var bench = benchmarks.shift();104 if (!bench) return;105 that.scrollToBenchmark(bench);106 that.runBenchmark(bench, function () {107 that.setState({state: 'ended'});108 next();109 });110 }, 500);111 },112 runBenchmark: function(name, outerCallback) {113 var that = this;114 var results = this.state.results[name];115 var maps = [];116 results.state = 'running';117 this.scrollToBenchmark(name);118 this.setState({runningBenchmark: name});119 log('dark', 'starting');120 this.props.benchmarks[name]({121 accessToken: getAccessToken(),122 createMap: createMap123 }).on('log', function(event) {124 log(event.color, event.message);125 }).on('end', function(event) {126 results.message = event.message;127 results.state = 'ended';128 log('green', event.message);129 callback();130 }).on('error', function(event) {131 results.state = 'errored';132 log('red', event.error);133 callback();134 });135 function log(color, message) {136 results.logs.push({137 color: color || 'blue',138 message: message139 });140 that.forceUpdate();141 }142 function callback() {143 for (var i = 0; i < maps.length; i++) {144 maps[i].remove();145 maps[i].getContainer().remove();146 }147 setTimeout(function() {148 that.setState({runningBenchmark: null});149 outerCallback();150 }, 500);151 }152 function createMap(options) {153 options = util.extend({width: 512, height: 512}, options);154 var element = document.createElement('div');155 element.style.width = options.width + 'px';156 element.style.height = options.height + 'px';157 element.style.margin = '0 auto';158 document.body.appendChild(element);159 var map = new mapboxgl.Map(util.extend({160 container: element,161 style: 'mapbox://styles/mapbox/streets-v9',162 interactive: false163 }, options));164 maps.push(map);165 return map;166 }167 }168});169var benchmarks = {170 'load-multiple-maps': require('./benchmarks/map_load'),171 buffer: require('./benchmarks/buffer'),172 fps: require('./benchmarks/fps'),173 'frame-duration': require('./benchmarks/frame_duration'),174 'query-point': require('./benchmarks/query_point'),175 'query-box': require('./benchmarks/query_box'),176 'geojson-setdata-small': require('./benchmarks/geojson_setdata_small'),177 'geojson-setdata-large': require('./benchmarks/geojson_setdata_large')178};179var filteredBenchmarks = {};180var benchmarkName = window.location.hash.substr(1);181if (!benchmarkName) {182 filteredBenchmarks = benchmarks;183} else {184 filteredBenchmarks[benchmarkName] = benchmarks[benchmarkName];185}186ReactDOM.render(<BenchmarksView benchmarks={filteredBenchmarks} />, document.getElementById('benchmarks'));187var clipboard = new Clipboard('.clipboard');188mapboxgl.accessToken = getAccessToken();189function getAccessToken() {190 var accessToken = (191 process.env.MapboxAccessToken ||192 process.env.MAPBOX_ACCESS_TOKEN ||193 getURLParameter('access_token') ||194 localStorage.getItem('accessToken')195 );196 localStorage.setItem('accessToken', accessToken);197 return accessToken;198}199function getURLParameter(name) {200 var regexp = new RegExp('[?&]' + name + '=([^&#]*)', 'i');201 var results = regexp.exec(window.location.href);202 return results && results[1];...

Full Screen

Full Screen

cli.ts

Source:cli.ts Github

copy

Full Screen

1#!/usr/bin/env node2import { InvalidOptionArgumentError, program } from 'commander';3import picomatch from 'picomatch';4import * as fs from 'fs';5import * as path from 'path';6import { getBenchmarks } from './catalog';7import { runBenchmark, RunBenchmarkOptions } from './runner';8import { printProgress, printResult } from './output';9import { BenchmarkEnvironment, HistoryEntry, loadHistory, saveHistory } from './history';10import { HighScoreConfig } from './cli-config';11/* eslint-disable no-console */12/* eslint-disable @typescript-eslint/no-var-requires */13const DEFAULT_OPTIONS: RunBenchmarkOptions = {14 minSampleDuration: 1,15 minSampleCount: 8,16 maxSampleCount: 32,17 timeout: false,18 runsPerSample: undefined,19 confirmationHeuristic: {20 sampleCount: 2,21 variance: 0.01,22 },23 cooldownHeuristic: {24 sampleCount: 3,25 },26 baselineHeuristic: {27 sampleCount: 32,28 variance: 0.01,29 },30};31const packageJson = require('../package.json');32// function intOption(str: string) {33// const num = parseInt(str, 10);34// if (isNaN(num)) {35// throw new InvalidOptionArgumentError('Not an integer');36// }37// return num;38// }39function floatOption(str: string) {40 const num = parseFloat(str);41 if (isNaN(num)) {42 throw new InvalidOptionArgumentError('Not a number');43 }44 return num;45}46program47 .version(packageJson.version)48 .option('-c, --config <file>', 'Specify the benchmark config file (default: bench.config.js)')49 .option('--log-dir <dir>', 'Specify the directory to put logs in (default: bench-log)')50 .option('-t, --include <pattern>', 'Runs only benchmarks matching a given regex')51 .option('--min-sample-duration <seconds>', 'Ensure that each sample takes at least this many seconds', floatOption)52 .option('--no-log', 'Don\'t save the results to the log')53 .option('--set-baseline', 'Mark these results as the "baseline" for future runs')54 .option('-q, --quiet', 'Prints only the results of the benchmarks (no progress)');55program.parse(process.argv);56const options = program.opts();57const configFile = path.resolve(options.config || './bench.config.js');58const configDir = path.dirname(configFile);59let config: HighScoreConfig = {};60if (fs.existsSync(configFile)) {61 config = require(configFile) as HighScoreConfig;62}63let moduleDir = configDir;64while (moduleDir) {65 if (fs.existsSync(path.join(moduleDir, 'package.json'))) {66 break;67 }68 moduleDir = path.dirname(moduleDir);69}70const moduleJson = moduleDir && require(path.join(moduleDir, 'package.json'));71const logDir = path.resolve(configDir, options.logDir || config.logDir || './bench-log');72function walk(dir: string, callback: (file: string) => void) {73 for (const name of fs.readdirSync(dir)) {74 const fullPath = path.join(dir, name);75 if (fs.statSync(fullPath).isDirectory()) {76 walk(fullPath, callback);77 } else {78 callback(fullPath);79 }80 }81}82const excludePaths = config.excludePaths || [ '**/node_modules/**' ];83const benchmarkPaths = config.benchmarkPaths || [ '**/*.bench.js' ];84const excludeMatcher = picomatch(excludePaths);85const includeMatcher = picomatch(benchmarkPaths);86const rootDir = config.rootDir ? path.resolve(configDir, config.rootDir) : configDir;87walk(rootDir, (file) => {88 const relPath = file.substring(rootDir.length + 1);89 if (!includeMatcher(relPath) || excludeMatcher(relPath)) {90 return;91 }92 require(file);93});94const includeStr = options.include;95const includeRegexp = includeStr && new RegExp(includeStr);96const benchmarks = getBenchmarks();97const filteredBenchmarks = benchmarks.filter((benchmark) => {98 return !includeRegexp || includeRegexp.test(benchmark.name);99});100const longestNameLength = filteredBenchmarks.reduce((sofar, benchmark) => Math.max(sofar, benchmark.name.length), 0);101const baseOptions = {102 ...DEFAULT_OPTIONS,103};104function copyOption<O, T extends (keyof RunBenchmarkOptions & keyof O)>(from: O, name: T) {105 if (from[name]) {106 // eslint-disable-next-line @typescript-eslint/no-explicit-any107 baseOptions[name] = from[name] as any;108 }109}110copyOption(config, 'timeout');111copyOption(options, 'minSampleDuration');112const environment: BenchmarkEnvironment = {113 nodeVersion: process.version,114 runnerVersion: packageJson.version,115 moduleName: config.moduleName ?? (moduleJson && moduleJson.name),116 moduleVersion: config.moduleVersion ?? (moduleJson && moduleJson.version),117};118console.log(`Running ${filteredBenchmarks.length} benchmark${filteredBenchmarks.length === 1 ? '' : 's'}...`);119function fixFilename(str: string) {120 let ret = '';121 for (const c of str) {122 if ('/\\?%*:|"<>.,= '.indexOf(c) >= 0) {123 ret += '-';124 } else {125 ret += c;126 }127 }128 return ret;129}130for (const benchmark of benchmarks) {131 const logPath = path.join(logDir, `${fixFilename(benchmark.name)}.log.json`);132 const history = loadHistory(logPath, benchmark.name);133 if (!includeRegexp || includeRegexp.test(benchmark.name)) {134 process.stdout.write(`${benchmark.name}: initializing...`);135 const benchOptions = {136 ...baseOptions,137 ...benchmark.options,138 };139 let baseline: HistoryEntry | undefined;140 if (history && typeof history.baseline !== 'undefined') {141 baseline = history.entries[history.baseline];142 }143 const result = runBenchmark(benchmark, benchOptions, baseline, (progress) => {144 if (!options.quiet) {145 printProgress(benchmark.name, progress);146 }147 });148 printResult(benchmark.name, longestNameLength, result, baseline);149 if (!options.noLog) {150 if (options.setBaseline) {151 history.baseline = history.entries.length;152 }153 history.entries.push({154 timestamp: new Date().toISOString(),155 result,156 environment,157 options: benchOptions,158 comment: benchmark.comment,159 version: benchmark.version,160 });161 saveHistory(history, logPath);162 }163 }...

Full Screen

Full Screen

worker.js

Source:worker.js Github

copy

Full Screen

1onmessage = function (e) {2 importScripts('../../fuse.js/js/fuse.min.js');3 let products = e.data.products;4 let benchmarks = e.data.benchmarks;5 const fuseOptions = {6 keys: ['name'],7 shouldSort: true,8 threshold: 0.49 };10 for (const pi in products) {11 let numbersInCpuName, numbersInGpuName;12 try {13 numbersInCpuName = products[pi].cpu.match(/\d+/g);14 numbersInGpuName = products[pi].gpu.match(/\d+/g);15 } catch (error) {16 console.error(products[pi]);17 }18 let largeNumbersInName = {};19 if (numbersInCpuName) {20 largeNumbersInName.cpu = Math.max(...numbersInCpuName);21 }22 if (numbersInGpuName) {23 largeNumbersInName.gpu = Math.max(...numbersInGpuName);24 }25 let filteredBenchmarks = {};26 for (const bti in Object.keys(benchmarks)) {27 let key = Object.keys(benchmarks)[bti];28 filteredBenchmarks[key] = [];29 for (const bci in benchmarks[key]) {30 if (largeNumbersInName[key]) {31 if (benchmarks[key][bci].name.includes(largeNumbersInName[key])) {32 filteredBenchmarks[key].push(benchmarks[key][bci]);33 }34 }35 }36 }37 const fuseCpus = new Fuse(filteredBenchmarks.cpu, fuseOptions);38 const fuseGpus = new Fuse(filteredBenchmarks.gpu, fuseOptions);39 cpuBenchmarkMatches = fuseCpus.search(products[pi].cpu);40 gpuBenchmarkMatches = fuseGpus.search(products[pi].gpu);41 let productBenchmarks;42 try {43 productBenchmarks = {44 cpuBenchmarkMatchName: cpuBenchmarkMatches && cpuBenchmarkMatches[0] ? cpuBenchmarkMatches[0].item.name : '',45 cpuBenchmarkMatchMark: cpuBenchmarkMatches && cpuBenchmarkMatches[0] ? cpuBenchmarkMatches[0].item.mark : '',46 gpuBenchmarkMatchName: cpuBenchmarkMatches && gpuBenchmarkMatches[0] ? gpuBenchmarkMatches[0].item.name : '',47 gpuBenchmarkMatchMark: cpuBenchmarkMatches && gpuBenchmarkMatches[0] ? gpuBenchmarkMatches[0].item.mark : ''48 };49 } catch (error) {50 console.error(error);51 console.error(products[pi]);52 }53 products[pi] = Object.assign(products[pi], productBenchmarks);54 if (parseInt(pi) > 0 && parseInt(pi) % 10 === 0) {55 postMessage({progress: (parseInt(pi) + 1)});56 }57 }58 postMessage({results: products});...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBenchmarks = require('./bestBenchmarks');2var bestBenchmarks = new BestBenchmarks();3var filteredBenchmarks = bestBenchmarks.filteredBenchmarks();4console.log(filteredBenchmarks);5var BestBenchmarks = require('./bestBenchmarks');6var bestBenchmarks = new BestBenchmarks();7var bestBenchmarks = bestBenchmarks.bestBenchmarks();8console.log(bestBenchmarks);

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBenchmarks = require('./bestBenchmarks');2var bestBenchmarks = new BestBenchmarks();3var filteredBenchmarks = bestBenchmarks.filteredBenchmarks(function (benchmark) {4 return benchmark.name == 'test';5});6console.log(filteredBenchmarks);

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBenchmarks = require('./BestBenchmarks.js');2var bestBenchmarks = new BestBenchmarks();3 { name: 'benchmark1', score: 10 },4 { name: 'benchmark2', score: 20 },5 { name: 'benchmark3', score: 30 },6 { name: 'benchmark4', score: 40 },7 { name: 'benchmark5', score: 50 }8];9var filteredBenchmarks = bestBenchmarks.filteredBenchmarks(benchmarks, 3);10console.log(filteredBenchmarks);11var BestBenchmarks = require('./BestBenchmarks.js');12var bestBenchmarks = new BestBenchmarks();13 { name: 'benchmark1', score: 10 },14 { name: 'benchmark2', score: 20 },15 { name: 'benchmark3', score: 30 },16 { name: 'benchmark4', score: 40 },17 { name: 'benchmark5', score: 50 }18];19var filteredBenchmarks = bestBenchmarks.filteredBenchmarks(benchmarks, 5);20console.log(filteredBenchmarks);21var BestBenchmarks = require('./BestBenchmarks.js');22var bestBenchmarks = new BestBenchmarks();23 { name: 'benchmark1', score: 10 },24 { name: 'benchmark2', score: 20 },25 { name: 'benchmark3', score: 30 },26 { name: 'benchmark4', score: 40 },27 { name: 'benchmark5', score: 50 }28];29var filteredBenchmarks = bestBenchmarks.filteredBenchmarks(benchmarks, 6);30console.log(filteredBenchmarks);31var BestBenchmarks = require('./BestBenchmarks.js');32var bestBenchmarks = new BestBenchmarks();33 { name: 'benchmark1', score: 10 },34 { name: 'benchmark2', score:

Full Screen

Using AI Code Generation

copy

Full Screen

1const BestBenchmarks = require('./BestBenchmarks');2let bestBenchmarks = new BestBenchmarks();3let filteredBenchmarks = bestBenchmarks.filteredBenchmarks('test1');4console.log(filteredBenchmarks);5[ { name: 'test1', score: 100 },6 { name: 'test2', score: 90 },7 { name: 'test3', score: 80 } ]8const BestBenchmarks = require('./BestBenchmarks');9let bestBenchmarks = new BestBenchmarks();10let filteredBenchmarks = bestBenchmarks.filteredBenchmarks('test2');11console.log(filteredBenchmarks);12[ { name: 'test2', score: 90 } ]13const BestBenchmarks = require('./BestBenchmarks');14let bestBenchmarks = new BestBenchmarks();15let filteredBenchmarks = bestBenchmarks.filteredBenchmarks('test3');16console.log(filteredBenchmarks);17[ { name: 'test3', score: 80 } ]18const BestBenchmarks = require('./BestBenchmarks');19let bestBenchmarks = new BestBenchmarks();20let filteredBenchmarks = bestBenchmarks.filteredBenchmarks('test4');21console.log(filteredBenchmarks);22const BestBenchmarks = require('./BestBenchmarks');23let bestBenchmarks = new BestBenchmarks();24let filteredBenchmarks = bestBenchmarks.filteredBenchmarks('test5');25console.log(filteredBenchmarks);

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBenchmarks = require('./BestBenchmarks');2var bestBenchmarks = new BestBenchmarks();3 {id: 1, name: 'test1', score: 100},4 {id: 2, name: 'test2', score: 200},5 {id: 3, name: 'test3', score: 300},6 {id: 4, name: 'test4', score: 400},7 {id: 5, name: 'test5', score: 500},8 {id: 6, name: 'test6', score: 600},9 {id: 7, name: 'test7', score: 700},10 {id: 8, name: 'test8', score: 800},11 {id: 9, name: 'test9', score: 900},12 {id: 10, name: 'test10', score: 1000}13];14var filteredBenchmarks = bestBenchmarks.filteredBenchmarks(benchmarks, 5);15console.log(filteredBenchmarks);

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBenchmarks = require('./BestBenchmarks.js');2var benchmarks = new BestBenchmarks();3benchmarks.filteredBenchmarks({4}, function(err, data) {5 if (err) {6 console.log(err);7 } else {8 console.log(data);9 }10});11var BestBenchmarks = require('./BestBenchmarks.js');12var benchmarks = new BestBenchmarks();13benchmarks.filteredBenchmarks({14}, function(err, data) {15 if (err) {16 console.log(err);17 } else {18 console.log(data);19 }20});21[ { category: 'CPU',

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBenchmarks = require('./BestBenchmarks.js');2var bestBenchmarks = new BestBenchmarks();3var cpu = "i5-4200U";4var gpu = "HD 4400";5var bestBenchmarksForCpuAndGpu = bestBenchmarks.filteredBenchmarks(cpu, gpu);6console.log(bestBenchmarksForCpuAndGpu);7MIT © [Siddharth Bhatia](

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBenchmarks = require("./BestBenchmarks");2var bestBenchmarks = new BestBenchmarks();3var benchs = bestBenchmarks.filteredBenchmarks("CPU", 3);4console.log("Best CPU benchmarks:");5benchs.forEach(function(bench) {6 console.log(bench);7});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Best automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful