import { DEFAULT_OPTIONS , UNGROUPED_NAME } from './constants' ; const hasOwnProperty = Object . prototype . hasOwnProperty ; param name param benchmarkGroup param benchmarkFn export const createBenchmark = ( name , benchmarkGroup , benchmarkFn ? ) : Benchee . Benchmark => ( { fn : typeof benchmarkGroup === 'function' ? benchmarkGroup : benchmarkFn , group : typeof benchmarkGroup === 'string' ? benchmarkGroup : UNGROUPED_NAME , iterations : 0 , name , } ) ; param passedOptions returns export const getOptions = ( passedOptions ? ) : Benchee . Options => passedOptions && typeof passedOptions === 'object' ? mergeObjects ( DEFAULT_OPTIONS , passedOptions ) : mergeObjects ( DEFAULT_OPTIONS ) ; param sources returns export const mergeObjects = ( ... sources ) : Object => { const target = { } ; let source ; for ( let index = 0 ; index < sources . length ; index ++ ) { source = sources [ index ] ; for ( const key in source ) { if ( hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ; returns export const now = ( ( ) => { try { performance . timing . navigationStart + performance . now ( ) ; return ( ) => performance . timing . navigationStart + performance . now ( ) ; } catch { try { const loadNs = process . hrtime ( ) ; const loadMs = Date . now ( ) ; const getCurrentTime = ( ) => { const diffNs = process . hrtime ( loadNs ) ; return ( loadMs * 1e6 + ( diffNs [ 0 ] * 1e9 + diffNs [ 1 ] ) ) / 1000000 ; } ; return getCurrentTime ; } catch { return ( ) => Date . now ( ) ; } } } ) ( ) ; param results returns export const sortResults = ( results ) : Benchee . Result [ ] => results . sort ( ( a , b ) : number => { if ( a . stats . ops > b . stats . ops ) { return - 1 ; } if ( a . stats . ops < b . stats . ops ) { return 1 ; } return 0 ; } ) ; param delay returns export const wait = ( delay = 0 ) : Promise < void > => new Promise ( ( resolve ) => setTimeout ( resolve , delay ) ) ;