Times a single function.
487187
def bench(func):
    """"""
    sys.stdout.write("%44s   " % format_func(func))
    sys.stdout.flush()

    # figure out how many times we have to run the function to
    # get reliable timings.
    for i in xrange(3, 10):
        rounds = 1 << i
        t = timer()
        for _ in xrange(rounds):
            func()
        if timer() - t >= 0.2:
            break

    # now run the tests without gc TEST_RUNS times and use the median
    # value of these runs.
    def _run():
        gc.collect()
        gc.disable()
        try:
            t = timer()
            for _ in xrange(rounds):
                func()
            return (timer() - t) / rounds * 1000
        finally:
            gc.enable()

    delta = median(_run() for x in xrange(TEST_RUNS))
    sys.stdout.write("%.4f\n" % delta)
    sys.stdout.flush()

    return delta
1233718
def _callable_once(func):
    

    def once(*args, **kwargs):
        if not once.called:
            once.called = True
            return func(*args, **kwargs)

    once.called = False
    return once
1352396
function( timeScale ) {

		if( timeScale !== 1.0 ) {

			var times = this.times;

			for( var i = 0, n = times.length; i !== n; ++ i ) {

				times[ i ] *= timeScale;

			}

		}

		return this;

	}
373370
def run_once(func):
    

    def _inner(*args, **kwargs):
        if func.__name__ in CTX.run_once:
            LOGGER.info('skipping %s', func.__name__)
            return CTX.run_once[func.__name__]

        LOGGER.info('running: %s', func.__name__)
        result = func(*args, **kwargs)
        CTX.run_once[func.__name__] = result
        return result

    return _inner
668941
function (fn) {
        /**
         * Chain function.
         *
         * @function
         * @memberof! funcs
         * @alias funcs.maxTimesChain
         * @private
         * @param {Number} times - The max times the provided function will be invoked
         * @returns {function} The new wrapper function
         */
        fn.maxTimes = function (times) {
            return funcs.maxTimes(fn, times);
        };

        /**
         * Chain function.
         *
         * @function
         * @memberof! funcs
         * @alias funcs.onceChain
         * @private
         * @returns {function} The new wrapper function
         */
        fn.once = function () {
            return funcs.once(fn);
        };

        /**
         * Chain function.
         *
         * @function
         * @memberof! funcs
         * @alias funcs.delayChain
         * @private
         * @param {Number} delay - The invocation delay in millies
         * @returns {function} The new wrapper function
         */
        fn.delay = function (delay) {
            return funcs.delay(fn, delay);
        };

        /**
         * Chain function.
         *
         * @function
         * @memberof! funcs
         * @alias funcs.asyncChain
         * @private
         * @returns {function} The new wrapper function
         */
        fn.async = function () {
            return funcs.async(fn);
        };
    }
374069
function( timeOffset ) {

		if( timeOffset !== 0.0 ) {

			var times = this.times;

			for( var i = 0, n = times.length; i !== n; ++ i ) {

				times[ i ] += timeOffset;

			}

		}

		return this;

	}
713840
def run_once(function, state={}, errors={}):
    """"""
    @six.wraps(function)
    def _wrapper(*args, **kwargs):
        if function in errors:
            # Deliberate use of LBYL.
            six.reraise(*errors[function])

        try:
            return state[function]
        except KeyError:
            try:
                state[function] = result = function(*args, **kwargs)
                return result
            except Exception:
                errors[function] = sys.exc_info()
                raise
    return _wrapper
917401
def wrap_function(self, func):
        
        def f(*args, **kwds):
            # Start time
            timestamps = [_get_memory(os.getpid(), timestamps=True)]
            self.functions[func].append(timestamps)
            try:
                result = func(*args, **kwds)
            finally:
                # end time
                timestamps.append(_get_memory(os.getpid(), timestamps=True))
            return result
        return f
73782
function (events, func) {
    for (var i = 0; i < events.length; i++) {
      obj.once(events[i], func)
      listeners[events[i]] = func
    }
  }
868338
def times(x, y):
    
    def decorator(fn):

        def wrapped(*args, **kwargs):
            n = random.randint(x, y)
            for z in range(1, n):
                fn(*args, **kwargs)

        return wrapped

    return decorator
19130
function once(fn) {
  var called, value;

  if (typeof fn !== 'function') {
    throw new Error('expected a function but got ' + fn);
  }

  return function wrap() {
    if (called) {
      return value;
    }
    called = true;
    value = fn.apply(this, arguments);
    fn = undefined;
    return value;
  };
}
992614
function time(key, fn) {
        if (typeof data[key] === "undefined") {
            data[key] = 0;
        }

        return function(...args) {
            let t = process.hrtime();

            fn(...args);
            t = process.hrtime(t);
            data[key] += t[0] * 1e3 + t[1] / 1e6;
        };
    }
86935
def timing(func):
    """"""
    @functools.wraps(func)
    def wrap(*args, **kw):
        t0 = time()
        result = func(*args, **kw)
        t1 = time()
        print('func:%r args:[%r, %r] took: %2.4f sec' %
              (func.__name__, args, kw, t1 - t0))
        return result
    return wrap
416188
public function times($times = null)
    {
        if (!func_num_args()) {
            return $this->_times;
        }
        $this->_times = $times;
        return $this;
    }
1369477
def times(self, multiplier):
		'''
			
		'''
		if multiplier < 0:
			raise Exception("Can't multiply an FSM by " + repr(multiplier))

		alphabet = self.alphabet

		# metastate is a set of iterations+states
		initial = {(self.initial, 0)}

		def final(state):
			'''If the initial state is final then multiplying doesn't alter that'''
			for (substate, iteration) in state:
				if substate == self.initial \
				and (self.initial in self.finals or iteration == multiplier):
					return True
			return False

		def follow(current, symbol):
			next = []
			for (substate, iteration) in current:
				if iteration < multiplier \
				and substate in self.map \
				and symbol in self.map[substate]:
					next.append((self.map[substate][symbol], iteration))
					# final of self? merge with initial on next iteration
					if self.map[substate][symbol] in self.finals:
						next.append((self.initial, iteration + 1))
			if len(next) == 0:
				raise OblivionError
			return frozenset(next)

		return crawl(alphabet, initial, final, follow).reduce()
1270308
def x_runtime(f, *args, **kwargs):
    """"""

    _t0 = now()
    r = f(*args, **kwargs)
    _t1 = now()
    r.headers['X-Runtime'] = '{0}s'.format(Decimal(str(_t1 - _t0)))

    return r
755841
def uniqify_once(func):
  """"""
  @six.wraps(func)
  def unique_once(self, *args, **kwargs):
    return self.unique_once(func(self, *args, **kwargs))
  return unique_once