How to use benchmarkFolder method in Best

Best JavaScript code snippet using best

inspector.js

Source:inspector.js Github

copy

Full Screen

1import * as THREE from 'three';2import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';3import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';4import { FullScreenQuad } from 'three/examples/jsm/postprocessing/Pass.js';5import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';6import {7 acceleratedRaycast, computeBoundsTree, disposeBoundsTree, MeshBVHVisualizer,8 SAH, CENTER, AVERAGE, getBVHExtremes, estimateMemoryInBytes,9} from '..';10THREE.Mesh.prototype.raycast = acceleratedRaycast;11THREE.BufferGeometry.prototype.computeBoundsTree = computeBoundsTree;12THREE.BufferGeometry.prototype.disposeBoundsTree = disposeBoundsTree;13let scene, camera, renderer, helper, mesh, outputContainer, benchmarkContainer;14let benchmarkViz, renderTarget, fsQuad;15let mouse = new THREE.Vector2();16const readBuffer = new Float32Array( 1 );17const modelPath = '../models/DragonAttenuation.glb';18const params = {19 options: {20 strategy: SAH,21 maxLeafTris: 10,22 maxDepth: 40,23 rebuild: function () {24 updateBVH();25 },26 },27 visualization: {28 displayMesh: true,29 simpleColors: false,30 outline: true,31 traversalThreshold: 50,32 },33 benchmark: {34 displayRays: false,35 firstHitOnly: true,36 rotations: 10,37 castCount: 1000,38 }39};40const BOUNDS_COLOR = 0xffca28;41const BG_COLOR = 0x002027;42const THRESHOLD_COLOR = 0xe91e63;43class TraverseMaterial extends THREE.ShaderMaterial {44 constructor( params ) {45 super( {46 uniforms: {47 map: { value: null },48 threshold: { value: 35 },49 boundsColor: { value: new THREE.Color( 0xffffff ) },50 backgroundColor: { value: new THREE.Color( 0x000000 ) },51 thresholdColor: { value: new THREE.Color( 0xff0000 ) },52 resolution: { value: new THREE.Vector2() },53 outlineAlpha: { value: 0.5 },54 },55 vertexShader: /* glsl */`56 varying vec2 vUv;57 void main() {58 vUv = uv;59 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );60 }61 `,62 fragmentShader: /* glsl */`63 uniform sampler2D map;64 uniform float threshold;65 uniform vec3 thresholdColor;66 uniform vec3 boundsColor;67 uniform vec3 backgroundColor;68 uniform vec2 resolution;69 uniform float outlineAlpha;70 varying vec2 vUv;71 void main() {72 float count = texture2D( map, vUv ).r;73 if ( count == 0.0 ) {74 vec2 offset = 1.0 / resolution;75 float c1 = texture2D( map, vUv + offset * vec2( 1.0, 0.0 ) ).r;76 float c2 = texture2D( map, vUv + offset * vec2( - 1.0, 0.0 ) ).r;77 float c3 = texture2D( map, vUv + offset * vec2( 0.0, 1.0 ) ).r;78 float c4 = texture2D( map, vUv + offset * vec2( 0.0, - 1.0 ) ).r;79 float maxC = max( c1, max( c2, max( c3, c4 ) ) );80 if ( maxC != 0.0 ) {81 gl_FragColor.rgb = mix( backgroundColor, mix( boundsColor, vec3( 1.0 ), 0.5 ), outlineAlpha );82 gl_FragColor.a = 1.0;83 return;84 }85 }86 if ( count > threshold ) {87 gl_FragColor.rgb = thresholdColor.rgb;88 gl_FragColor.a = 1.0;89 } else {90 float alpha = count / threshold;91 vec3 color = mix( boundsColor, vec3( 1.0 ), pow( alpha, 1.75 ) );92 gl_FragColor.rgb = mix( backgroundColor, color, alpha ).rgb ;93 gl_FragColor.a = 1.0;94 }95 }96 `,97 } );98 const uniforms = this.uniforms;99 for ( const key in uniforms ) {100 Object.defineProperty( this, key, {101 get() {102 return this.uniforms[ key ].value;103 },104 set( v ) {105 this.uniforms[ key ].value = v;106 }107 } );108 }109 this.setValues( params );110 }111}112function init() {113 outputContainer = document.getElementById( 'output' );114 benchmarkContainer = document.getElementById( 'benchmark' );115 // renderer setup116 renderer = new THREE.WebGLRenderer( { antialias: true } );117 renderer.setPixelRatio( window.devicePixelRatio );118 renderer.setSize( window.innerWidth, window.innerHeight );119 renderer.setClearColor( 0, 1 );120 document.body.appendChild( renderer.domElement );121 // render target122 renderTarget = new THREE.WebGLRenderTarget( 1, 1, {123 format: THREE.RedFormat,124 type: THREE.FloatType,125 // TODO: Use integer buffers once better supported in three.js126 // format: THREE.RedIntegerFormat,127 // type: THREE.UnsignedIntType,128 // internalFormat: 'R16UI'129 } );130 fsQuad = new FullScreenQuad( new TraverseMaterial( {131 map: renderTarget.texture,132 depthWrite: false,133 } ) );134 // scene setup135 scene = new THREE.Scene();136 // camera setup137 camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 50 );138 camera.position.set( - 2.5, 1.5, 2.5 );139 camera.far = 100;140 camera.updateProjectionMatrix();141 new OrbitControls( camera, renderer.domElement );142 window.addEventListener( 'resize', onResize, false );143 onResize();144 // Load dragon145 const loader = new GLTFLoader();146 loader.load( modelPath, gltf => {147 gltf.scene.traverse( c => {148 if ( c.isMesh && c.name === 'Dragon' ) {149 mesh = c;150 }151 } );152 mesh.material = new THREE.MeshBasicMaterial( { colorWrite: false } );153 mesh.geometry.center();154 mesh.position.set( 0, 0, 0 );155 scene.add( mesh );156 helper = new MeshBVHVisualizer( mesh, 40 );157 helper.displayEdges = false;158 helper.displayParents = true;159 helper.color.set( 0xffffff );160 helper.opacity = 1;161 helper.depth = 40;162 const material = helper.meshMaterial;163 material.blending = THREE.CustomBlending;164 material.blendDst = THREE.OneFactor;165 scene.add( helper );166 updateBVH();167 runBenchmark( true );168 } );169 benchmarkViz = new THREE.LineSegments();170 benchmarkViz.material.opacity = 0.1;171 benchmarkViz.material.transparent = true;172 benchmarkViz.material.depthWrite = false;173 benchmarkViz.frustumCulled = false;174 scene.add( benchmarkViz );175 const gui = new GUI();176 const bvhFolder = gui.addFolder( 'BVH' );177 bvhFolder.add( params.options, 'strategy', { CENTER, AVERAGE, SAH } );178 bvhFolder.add( params.options, 'maxLeafTris', 1, 30, 1 );179 bvhFolder.add( params.options, 'maxDepth', 1, 40, 1 );180 bvhFolder.add( params.options, 'rebuild' );181 bvhFolder.open();182 const vizFolder = gui.addFolder( 'Visualization' );183 vizFolder.add( params.visualization, 'displayMesh' );184 vizFolder.add( params.visualization, 'simpleColors' );185 vizFolder.add( params.visualization, 'outline' );186 vizFolder.add( params.visualization, 'traversalThreshold', 1, 300, 1 );187 vizFolder.open();188 const benchmarkFolder = gui.addFolder( 'Benchmark' );189 benchmarkFolder.add( params.benchmark, 'displayRays' );190 benchmarkFolder.add( params.benchmark, 'firstHitOnly' ).onChange( resetBenchmark );191 benchmarkFolder.add( params.benchmark, 'castCount', 100, 5000, 1 ).onChange( () => {192 resetBenchmark();193 runBenchmark( true );194 } );195 benchmarkFolder.add( params.benchmark, 'rotations', 1, 20, 1 ).onChange( () => {196 resetBenchmark();197 runBenchmark( true );198 } );199 benchmarkFolder.open();200 window.addEventListener( 'pointermove', e => {201 mouse.set( e.clientX, window.innerHeight - e.clientY );202 } );203}204function onResize() {205 camera.aspect = window.innerWidth / window.innerHeight;206 camera.updateProjectionMatrix();207 renderer.setSize( window.innerWidth, window.innerHeight );208 renderer.setPixelRatio( window.devicePixelRatio );209 renderTarget.setSize(210 window.innerWidth * window.devicePixelRatio,211 window.innerHeight * window.devicePixelRatio,212 );213}214function updateBVH() {215 const startTime = performance.now();216 mesh.geometry.computeBoundsTree( {217 strategy: parseInt( params.options.strategy ),218 maxLeafTris: params.options.maxLeafTris,219 maxDepth: params.options.maxDepth,220 } );221 const deltaTime = performance.now() - startTime;222 helper.update();223 resetBenchmark();224 const info = getBVHExtremes( mesh.geometry.boundsTree )[ 0 ];225 outputContainer.innerText =226 `construction time : ${ deltaTime.toFixed( 2 ) }ms\n` +227 `surface area score : ${ info.surfaceAreaScore.toFixed( 2 ) }\n` +228 `total nodes : ${ info.nodeCount }\n` +229 `total leaf nodes : ${ info.leafNodeCount }\n` +230 `min / max tris per leaf : ${ info.tris.min } / ${ info.tris.max }\n` +231 `min / max depth : ${ info.depth.min } / ${ info.depth.max }\n` +232 `memory (incl. geometry) : ${ ( estimateMemoryInBytes( mesh.geometry.boundsTree ) * 1e-6 ).toFixed( 3 ) } mb \n` +233 `memory (excl. geometry) : ${ ( estimateMemoryInBytes( mesh.geometry.boundsTree._roots ) * 1e-6 ).toFixed( 3 ) } mb`;234}235function runBenchmark( updateGeom = false ) {236 let points = null;237 let newGeometry = null;238 if ( updateGeom ) {239 mesh.updateMatrixWorld();240 newGeometry = new THREE.BufferGeometry();241 benchmarkViz.geometry.dispose();242 points = [];243 }244 const raycaster = new THREE.Raycaster();245 raycaster.firstHitOnly = params.benchmark.firstHitOnly;246 const rayCount = params.benchmark.castCount;247 const rotations = params.benchmark.rotations;248 const { ray } = raycaster;249 const { origin, direction } = ray;250 const startTime = performance.now();251 for ( let i = 0; i < rayCount; i ++ ) {252 const step = i / rayCount;253 const y = step - 0.5;254 origin.set(255 Math.cos( 0.75 * Math.PI * y ) * Math.sin( rotations * 2 * Math.PI * i / rayCount ),256 2 * y,257 Math.cos( 0.75 * Math.PI * y ) * Math.cos( rotations * 2 * Math.PI * i / rayCount ),258 ).multiplyScalar( 2.5 );259 direction.set(260 Math.cos( rotations * 5 * y ),261 Math.sin( rotations * 10 * y ),262 Math.sin( rotations * 5 * y ),263 ).sub( origin ).normalize();264 raycaster.intersectObject( mesh );265 if ( updateGeom ) {266 const hit = raycaster.intersectObject( mesh )[ 0 ];267 points.push( origin.clone() );268 if ( hit ) {269 points.push( hit.point.clone() );270 } else {271 const v = new THREE.Vector3();272 ray.at( 5, v );273 points.push( v );274 }275 }276 }277 const deltaTime = performance.now() - startTime;278 if ( updateGeom ) {279 newGeometry.setFromPoints( points );280 benchmarkViz.geometry = newGeometry;281 }282 return deltaTime;283}284let sampleCount = 0;285let currTime = 0;286function resetBenchmark() {287 sampleCount = 0;288 currTime = 0;289}290function render() {291 requestAnimationFrame( render );292 // read the buffer from the last frame of rendering so we don't block293 // waiting for this frame to finish.294 const pixelRatio = renderer.getPixelRatio();295 renderer.readRenderTargetPixels(296 renderTarget,297 mouse.x * pixelRatio, mouse.y * pixelRatio, 1, 1,298 readBuffer,299 );300 if ( mesh ) {301 sampleCount = Math.min( sampleCount + 1, 50 );302 currTime += ( runBenchmark() - currTime ) / sampleCount;303 benchmarkContainer.innerText =304 `\ntraversal depth at mouse : ${ Math.round( readBuffer[ 0 ] ) }\n` +305 `benchmark rolling avg : ${ currTime.toFixed( 3 ) } ms`;306 }307 if ( params.visualization.simpleColors ) {308 fsQuad.material.boundsColor.set( 0xffffff );309 fsQuad.material.thresholdColor.set( 0xff0000 );310 fsQuad.material.backgroundColor.set( 0x000000 );311 } else {312 fsQuad.material.boundsColor.set( BOUNDS_COLOR );313 fsQuad.material.thresholdColor.set( THRESHOLD_COLOR );314 fsQuad.material.backgroundColor.set( BG_COLOR );315 }316 fsQuad.material.threshold = params.visualization.traversalThreshold;317 fsQuad.material.outlineAlpha = params.visualization.outline ? 0.5 : 0.0;318 fsQuad.material.resolution.set( renderTarget.width, renderTarget.height );319 // render bvh320 benchmarkViz.visible = false;321 renderer.autoClear = true;322 if ( mesh ) mesh.visible = params.visualization.displayMesh;323 renderer.setRenderTarget( renderTarget );324 renderer.render( scene, camera );325 renderer.setRenderTarget( null );326 fsQuad.render( renderer );327 // render rays328 renderer.autoClear = false;329 benchmarkViz.visible = params.benchmark.displayRays;330 if ( mesh ) renderer.render( mesh, camera );331 renderer.render( benchmarkViz, camera );332}333init();...

Full Screen

Full Screen

tester-utils.ts

Source:tester-utils.ts Github

copy

Full Screen

1import { BenchmarkInfo } from './benchmarks';2import { relative, resolve } from 'path';3import {4 AFL_INSTRUMENTER_BIN,5 BENCHMARKS_FOLDER,6 CANARIES_INSTRUMENTER_BIN,7 LAVA_BENCHMARKS_FOLDER,8} from '../constants';9import { exec, ExecException } from 'child_process';10export function getBenchmarkFolder(benchmarkName: string): string {11 if (['base64', 'uniq', 'md5sum'].some((b) => b === benchmarkName)) {12 return resolve(LAVA_BENCHMARKS_FOLDER, benchmarkName);13 }14 return resolve(BENCHMARKS_FOLDER, benchmarkName);15}16export function getDiffTestFolder(benchmarkName: string): string {17 return resolve(getBenchmarkFolder(benchmarkName), 'differential-tests');18}19export async function insertCanaries(20 bin: string,21 binOut: string,22 skipHeap: boolean = false,23 skipStack: boolean = false24): Promise<void> {25 const instrumentCmd = `${CANARIES_INSTRUMENTER_BIN} ${bin} ${binOut} --skip-print ${skipHeap ? '--skip-heap' : ''} ${26 skipStack ? '--skip-stack' : ''27 }`;28 await new Promise<void>((res, rej) => {29 exec(instrumentCmd, (err, stdout, stderr) => {30 if (err) {31 console.log(stdout, stderr);32 rej();33 }34 res();35 });36 });37}38export async function insertAFLInstrumentation(bin: string, binOut: string): Promise<void> {39 const instrumentCmd = `${AFL_INSTRUMENTER_BIN} ${bin} ${binOut}`;40 await new Promise<void>((res, rej) => {41 exec(instrumentCmd, (err, stdout, stderr) => {42 if (err) {43 console.log(stdout, stderr);44 rej();45 }46 res();47 });48 });49}50export async function execute<T>(51 binary: string,52 testFilePath: string,53 outFilePrefix: string,54 benchmarkFolder: string,55 bMarkInfo: BenchmarkInfo,56 cb: (e: ExecException | null, out: string, err: string, timeMS: number) => T57): Promise<T> {58 let cmdTestFilePath = testFilePath;59 if (bMarkInfo.useRelativeInput) {60 cmdTestFilePath = relative(benchmarkFolder, cmdTestFilePath);61 }62 const cmd = bMarkInfo.cmd.replace('@@', cmdTestFilePath).replace('##', outFilePrefix);63 const wasmCmd = `wasmtime ${binary} --dir=${bMarkInfo.useRelativeInput ? '.' : '/'} -- ${cmd}`;64 return new Promise((res) => {65 const hrstart = process.hrtime();66 exec(wasmCmd, { cwd: benchmarkFolder, encoding: 'utf-8' }, (err, stdout, stderr) => {67 const hrend = process.hrtime(hrstart);68 res(cb(err, stdout, stderr, hrend[0] * 1000 + hrend[1] / 1000000));69 });70 });...

Full Screen

Full Screen

LoadKernel.js

Source:LoadKernel.js Github

copy

Full Screen

1laraImport("lara.Io");2laraImport("clava.Clava");3laraImport("weaver.Query");4function loadBenchmark(benchmarkName, extraFlags = "") {5 println(`Loading ${benchmarkName}`);6 const config = Clava.getData();7 const currentFolderFolder = config.getContextFolder();8 config.setFlags("-Wall -pedantic -DRUN_CLAVA " + extraFlags);9 const benchmarkFolder = Io.getPath(currentFolderFolder, "./benchmarks");10 const kernelFile = Io.getPath(benchmarkFolder, benchmarkName + "/kernel.c");11 /* Make Commun.h accessible to compile kernel.c */12 config.setUserIncludes(benchmarkFolder.getAbsolutePath());13 Query.root().addFileFromPath(kernelFile);14 Clava.rebuild();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var path = require('path');3var Benchmark = require('benchmark');4var suite = new Benchmark.Suite;5var bestPractices = require('./bestPractices.js');6var testFolder = './testFolder';7suite.add('Benchmarking folder', function() {8 bestPractices.benchmarkFolder(testFolder);9})10.on('cycle', function(event) {11 console.log(String(event.target));12})13.run({ 'async': true });

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBenchmark = require('./BestBenchmark.js');2var benchmark = new BestBenchmark();3var folder = 'testFolder';4benchmark.benchmarkFolder(folder, function(err, data) {5 if (err) {6 console.log(err);7 }8 else {9 console.log(data);10 }11});12var BestBenchmark = require('./BestBenchmark.js');13var benchmark = new BestBenchmark();14var file = 'testFolder/testFile';15benchmark.benchmarkFile(file, function(err, data) {16 if (err) {17 console.log(err);18 }19 else {20 console.log(data);21 }22});23var BestBenchmark = require('./BestBenchmark.js');24var benchmark = new BestBenchmark();25var file = 'testFolder/testFile';26benchmark.benchmarkFile(file, function(err, data) {27 if (err) {28 console.log(err);29 }30 else {31 console.log(data);32 }33});34var BestBenchmark = require('./BestBenchmark.js');35var benchmark = new BestBenchmark();36var file = 'testFolder/testFile';37benchmark.benchmarkFile(file, function(err, data) {38 if (err) {39 console.log(err);40 }41 else {42 console.log(data);43 }44});45var BestBenchmark = require('./BestBenchmark.js');46var benchmark = new BestBenchmark();47var file = 'testFolder/testFile';48benchmark.benchmarkFile(file, function(err, data) {49 if (err) {50 console.log(err);51 }52 else {53 console.log(data);54 }55});56var BestBenchmark = require('./BestBenchmark.js');57var benchmark = new BestBenchmark();58var file = 'testFolder/testFile';59benchmark.benchmarkFile(file, function(err, data) {60 if (err) {61 console.log(err);62 }63 else {64 console.log(data);65 }66});67var BestBenchmark = require('./BestBenchmark.js');68var benchmark = new BestBenchmark();

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestPracticeChecker = require('./BestPracticeChecker.js');2var fs = require('fs');3var checker = new BestPracticeChecker();4var folderPath = './test4';5var results = checker.benchmarkFolder(folderPath);6fs.writeFile("test4.json", JSON.stringify(results), function(err) {7 if(err) {8 return console.log(err);9 }10 console.log("The file was saved!");11});

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBenchmark = require("./BestBenchmark");2var path = require("path");3var fs = require("fs");4var util = require("util");5var benchmark = new BestBenchmark();6var path = path.join(__dirname, "test4");7var result = benchmark.benchmarkFolder(path, true);

Full Screen

Using AI Code Generation

copy

Full Screen

1var bestTime = require('best-time');2var path = require('path');3var folderPath = path.join(__dirname, 'testScripts');4bestTime.benchmarkFolder(folderPath, function(err, results) {5 if (err) {6 console.log(err);7 } else {8 console.log(results);9 }10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var benchmark = require('./benchmark.js');2var folder = process.argv[2];3var result = benchmark.benchmarkFolder(folder, function(err, data){4 if(err){5 console.log(err);6 } else {7 console.log(data);8 }9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBenchmark = require('./bestBenchmark.js');2var bench = new BestBenchmark();3bench.benchmarkFolder(__dirname + '/testFolder', function(err, res) {4 console.log(res);5});6#### benchmarkFolder(folderPath, [options], callback)

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBenchmark = require('bestbenchmark');2var fs = require('fs');3var benchmark = new BestBenchmark();4benchmark.benchmarkFolder('./testFolder', 1000, 1000, function(err, result){5 if(err){6 console.log(err);7 return;8 }9 fs.writeFile('benchmarkResult.txt', result, function(err){10 if(err){11 console.log(err);12 return;13 }14 console.log('benchmarkResult.txt created!');15 });16});17### benchmarkFolder(folderPath, iterations, warmup, callback)

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBenchmark = require('./BestBenchmark.js');2var path = require('path');3var bb = new BestBenchmark();4var folder = path.join(__dirname, 'testFolder');5bb.benchmarkFolder(folder, function(err, results) {6 if(err) {7 console.log(err);8 } else {9 console.log(results);10 }11});12var BestBenchmark = require('./BestBenchmark.js');13var bb = new BestBenchmark();14var test = function() {15 var x = 0;16 for(var i = 0; i < 1000000; i++) {17 x++;18 }19};20bb.benchmark(test, function(err, results) {21 if(err) {22 console.log(err);23 } else {24 console.log(results);25 }26});27var BestBenchmark = require('./BestBenchmark.js');28var bb = new BestBenchmark();29var test = function() {30 var x = 0;31 for(var i = 0; i < 1000000; i++) {32 x++;33 }34};35bb.benchmark(test, function(err, results) {36 if(err) {37 console.log(err);38 } else {39 console.log(results);40 }41});42var BestBenchmark = require('./BestBenchmark.js');43var bb = new BestBenchmark();44var test = function() {45 var x = 0;46 for(var i = 0; i < 1000000; i++) {47 x++;48 }49};50bb.benchmark(test, function(err, results) {51 if(err) {52 console.log(err);53 } else {54 console.log(results);55 }56});57var BestBenchmark = require('./BestBenchmark.js');58var bb = new BestBenchmark();59var test = function() {60 var x = 0;61 for(var i = 0;

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