10 minutes in msec - this will become a param
171026
function ParamedicRunner(_platformId,_plugins,_callback,bJustBuild,nPort,msTimeout,browserify,bSilent,bVerbose,platformPath) {
    this.tunneledUrl = "";
    this.port = nPort;
    this.justBuild = bJustBuild;
    this.plugins = _plugins;
    this.platformId = _platformId;
    this.callback = _callback;
    this.tempFolder = null;
    this.timeout = msTimeout;
    this.verbose = bVerbose;
    this.platformPath = platformPath;

    if(browserify) {
        this.browserify = "--browserify";
    } else {
        this.browserify = '';
    }
    
    if(bSilent) {
        var logOutput = this.logOutput = [];
        this.logMessage = function(msg) {
            logOutput.push(msg);
        };
    }
    else {
        this.logMessage = function(msg) {
            console.log(msg);
        };
    }
}
555072
def _get_proc_create_time(proc):
    '''
    
    '''
    try:
        return salt.utils.data.decode(proc.create_time() if PSUTIL2 else proc.create_time)
    except (psutil.NoSuchProcess, psutil.AccessDenied):
        return None
328143
private synchronized void checkNextSecond(double nowInMsRoundedAtSec) {
        // next second
        if (time == nowInMsRoundedAtSec) {
            return;
        }

        if (startSec == 0) {
            startSec = nowInMsRoundedAtSec;
        }
        time = nowInMsRoundedAtSec;

        Pair<Double, Long> pair = getRPSForSecond((nowInMsRoundedAtSec - startSec) / 1000);
        double nextRps = pair.getLeft();
        if (nextRps < 0) {
            stopping = true;
            int factor = stopTries > 10 ? 2 : 1;
            rps = rps > 0 ? rps * factor : 1;
            stopTest();
            notifyAll();
        } else {
            rps = nextRps;
        }

        if (log.isDebugEnabled()) {
            log.debug("Second changed {} , waiting: {}, samples sent {}, current rps: {} rps",
                    ((nowInMsRoundedAtSec - startSec) / 1000), cntDelayed, cntSent, rps);
        }

        if (cntDelayed < 1 && cntSent < rps) {
            log.warn("No free threads available in current Thread Group {}, made {} samples/s for expected rps {} samples/s, increase your number of threads",
                    JMeterContextService.getContext().getThreadGroup().getName(), cntSent, rps);
        }

        String elementName = getName();
        JMeterUtils.setProperty(elementName + "_totalDuration", String.valueOf(pair.getRight()));
        JMeterUtils.setProperty(elementName + "_cntDelayed", String.valueOf(cntDelayed));
        JMeterUtils.setProperty(elementName + "_cntSent", String.valueOf(cntSent));
        JMeterUtils.setProperty(elementName + "_rps", String.valueOf(rps));

        cntSent = 0;
        msecPerReq = 1000d / rps;
    }
257702
function({_t0, arg, keys, inv}) {
		const key = keys && makeKey(opts, keys);
		const lay = layers.map(l => l.instantiate({key, ttl, ttr, inv}));
		const fix = lay.slice();
		const ret = Q.defer();
		const bld = () => {
			const _t1 = new Date;
			return Q()
				.then(() => func.apply(this, arg))
				.then(val => {
					time('build', new Date - _t1);
					return val;
				});
		}

		const set = (layer, val) => {
			if (shouldCache(val)) {
				layer.set(val);
			}
		}

		const pump = () => {

			// Get the next layer.
			const cur = lay.shift();
			const _t1 = new Date;

			// If we couldn't make a key, then we force a miss.
			// If we're out of layers, then we'll just have to
			// build.  It's a full miss.
			// We can _force_ a miss with the `_bust` parameter.
			if (!key || !cur || force()) {
				bld().then(val => {

					// Hand it off.
					ret.resolve(val)

					// Sob about it.
					time('miss', new Date - _t0);

				// Patch rejection through to return promise.
				}).catch(err => ret.reject(err));
				return;
			}

			Q().then(() => cur.get()).then(() => {

				// If we found a value and it's not expired.
				if (cur.val && !cur.exp) {

					// Hand it off.
					ret.resolve(cur.val);

					// Brag about it.
					time('hit', new Date - _t0);
					time(`layer.${cur.name()}.hit.fromStart`,  new Date - _t0);
					time(`layer.${cur.name()}.hit.individual`, new Date - _t1);

					// If our time-to-rebuild has elapsed,
					// we'll rebuild in the background and
					// populate the new value into all
					// layers.
					if (cur.red) {
						bld().then((val) => {
							fix.forEach(layer => set(layer, val));
						}).catch(() => {
							time('error.background', new Date - _t0);
						});

					}
				} else {

					// Miss.  Populate this layer later
					// when we get a value.
					ret.promise.then(val => set(cur, val));

					time(`layer.${cur.name()}.miss.fromStart`,  new Date - _t0);
					time(`layer.${cur.name()}.miss.individual`, new Date - _t1);

					// Try the next layer.
					pump();
				}
			});
		}

		if (inv) {
			// Invalidate.
			Q.all(fix.map(l => l.set())).then(ret.resolve);
		} else {
			// Start looking!
			pump();
		}

		// Log if we reject.
		ret.promise.catch(() => time('error.returned', new Date - _t0));

		// We'll find it, we promise!
		return ret.promise

			// Post-processing on the way out of the cache.
			.then(after)

			// Down and to the right!
			.then(v => (time('overall', new Date - _t0), v))
	}
996399
def call(sev, time, _, msg) #:nodoc:
      level = ({
          Logger::DEBUG   => 'DEBUG',
          Logger::INFO    => 'INFO',
          Logger::WARN    => 'WARN',
          Logger::ERROR   => 'ERROR',
          Logger::FATAL   => 'FATAL',
      }[sev] || sev.to_s).upcase

      if msg.present? && AUTO_DEBUG_PATTERNS.find{|pattern| msg =~ pattern}
        return '' if debug_skip?
        level = 'DEBUG'
      end

      if msg.present?
        # And we'll expand exceptions so we get as much info as possible.
        # If you just want the message, make sure you just pass the message.
        if msg.is_a?(::Exception)
          msg = "#{msg.message} (#{msg.class})\n#{(msg.backtrace || []).join("\n")}"
        elsif !msg.is_a?(::String)
          msg = msg.inspect
        end

        msg = rm_fmt msg

        {
            level: level,
            time: time.strftime('%Y-%m-%d %H:%M:%S'),
            message: msg,
            app_name: app_name,
            app_version: app_version,
            process_id: Process.pid,
        }.to_json + "\r\n"
      else
        ''
      end
    end
841434
public static void main(String[] args) throws IOException, InterruptedException {
    // Register the view. It is imperative that this step exists,
    // otherwise recorded metrics will be dropped and never exported.
    View view =
        View.create(
            Name.create("task_latency_distribution"),
            "The distribution of the task latencies.",
            LATENCY_MS,
            Aggregation.Distribution.create(LATENCY_BOUNDARIES),
            Collections.<TagKey>emptyList());

    // Create the view manager
    ViewManager viewManager = Stats.getViewManager();

    // Then finally register the views
    viewManager.registerView(view);

    // [START setup_exporter]
    // Enable OpenCensus exporters to export metrics to Stackdriver Monitoring.
    // Exporters use Application Default Credentials to authenticate.
    // See https://developers.google.com/identity/protocols/application-default-credentials
    // for more details.
    StackdriverStatsExporter.createAndRegister();
    // [END setup_exporter]

    // Record 100 fake latency values between 0 and 5 seconds.
    Random rand = new Random();
    for (int i = 0; i < 100; i++) {
      long ms = (long) (TimeUnit.MILLISECONDS.convert(5, TimeUnit.SECONDS) * rand.nextDouble());
      System.out.println(String.format("Latency %d: %d", i, ms));
      STATS_RECORDER.newMeasureMap().put(LATENCY_MS, ms).record();
    }

    // The default export interval is 60 seconds. The thread with the StackdriverStatsExporter must
    // live for at least the interval past any metrics that must be collected, or some risk being
    // lost if they are recorded after the last export.

    System.out.println(
        String.format(
            "Sleeping %d seconds before shutdown to ensure all records are flushed.",
            EXPORT_INTERVAL));
    Thread.sleep(TimeUnit.MILLISECONDS.convert(EXPORT_INTERVAL, TimeUnit.SECONDS));
  }
609172
protected void setTiming(boolean monitor, long t0, MessageToClient mtc) {
		if (monitor) {
			long t1 = System.currentTimeMillis();
			mtc.setTime(t1 - t0);
		}
	}
430008
def psetex(self, key, milliseconds, value):
        
        if not isinstance(milliseconds, int):
            raise TypeError("milliseconds argument must be int")
        fut = self.execute(b'PSETEX', key, milliseconds, value)
        return wait_ok(fut)
78345
async def psetex(self, name, time_ms, value):
        
        if isinstance(time_ms, datetime.timedelta):
            ms = int(time_ms.microseconds / 1000)
            time_ms = (time_ms.seconds + time_ms.days * 24 * 3600) * 1000 + ms
        return await self.execute_command('PSETEX', name, time_ms, value)
880927
public String getMilliseconds() {
        if (myTimerIsRunning) {
            throw new IllegalStateException(LOGGER.getI18n(MessageCodes.UTIL_042));
        }

        return new StringBuilder().append(myStop - myStart).append(" msecs").toString();
    }
875706
def timestr(msec):
    
    sec = float(msec) / 1000

    hours = int(sec / 3600)
    sec -= hours * 3600

    minutes = int(sec / 60)
    sec -= minutes * 60

    output = "%02d:%02d:%06.3f" % (hours, minutes, sec)
    return output.replace(".", ",")
392408
private static String getDuration(long millis) {
        long tsec = millis / 1000;
        long h = tsec / 60 / 60;
        long m = (tsec - h * 60 * 60) / 60;
        long s = tsec - h * 60 * 60 - m * 60;
        StringBuffer out = new StringBuffer();
        if (h > 0) {
            out.append(h + " hour");
            if (h > 1) {
                out.append('s');
            }
        }
        if (m > 0) {
            if (h > 0) {
                out.append(", ");
            }
            out.append(m + " minute");
            if (m > 1) {
                out.append('s');
            }
        }
        if (s > 0 || h == 0 && m == 0) {
            if (h > 0 || m > 0) {
                out.append(", ");
            }
            out.append(s + " second");
            if (s != 1) {
                out.append('s');
            }
        }
        return out.toString();
    }
995658
function( time, callback ) {
		var self = this, timeid;

		// Can only delay an active module
		self.requireState( munit.ASSERT_STATE_ACTIVE, self.delay );

		// Time parameter is required
		if ( ! munit.isNumber( time ) ) {
			throw new munit.AssertionError( "Time parameter not passed to assert.delay", self.delay );
		}

		// Module has yet to complete the callback cycle,
		// Start async extension now
		if ( ! self.isAsync ) {
			self.isAsync = true;
			self.options.timeout = time;
			self._timerStart = Date.now();
			self._timeid = timeid = setTimeout(function(){
				if ( munit.isFunction( callback ) ) {
					callback( self );
				}

				if ( timeid === self._timeid && self.state < munit.ASSERT_STATE_TEARDOWN ) {
					self.close();
				}
			}, time );
		}
		// Only extend current timeout if it is less then requested delay
		else if ( ( self._timerStart + self.options.timeout ) < ( Date.now() + time ) ) {
			if ( self._timeid ) {
				self._timeid = clearTimeout( self._timeid );
			}

			self.isAsync = true;
			self._timerStart = Date.now();
			self._timeid = timeid = setTimeout(function(){
				if ( munit.isFunction( callback ) ) {
					callback( self );
				}

				if ( timeid === self._timeid && self.state < munit.ASSERT_STATE_TEARDOWN ) {
					self.close();
				}
			}, time );
		}
		// Force block any delay that does not extend longer than current timeout
		else {
			throw new munit.AssertionError( "delay time doesn't extend further than the current timeout", self.delay );
		}
	}
978093
def process_master(m):
    ''''''
    try:
        s = m.recv(16*1024)
    except Exception:
        time.sleep(0.1)
        return
    # prevent a dead serial port from causing the CPU to spin. The user hitting enter will
    # cause it to try and reconnect
    if len(s) == 0:
        time.sleep(0.1)
        return

    if (mpstate.settings.compdebug & 1) != 0:
        return

    if mpstate.logqueue_raw:
        mpstate.logqueue_raw.put(str(s))

    if mpstate.status.setup_mode:
        if mpstate.system == 'Windows':
           # strip nsh ansi codes
           s = s.replace("\033[K","")
        sys.stdout.write(str(s))
        sys.stdout.flush()
        return

    if m.first_byte and opts.auto_protocol:
        m.auto_mavlink_version(s)
    msgs = m.mav.parse_buffer(s)
    if msgs:
        for msg in msgs:
            sysid = msg.get_srcSystem()
            if sysid in mpstate.sysid_outputs:
                  # the message has been handled by a specialised handler for this system
                  continue
            if getattr(m, '_timestamp', None) is None:
                m.post_message(msg)
            if msg.get_type() == "BAD_DATA":
                if opts.show_errors:
                    mpstate.console.writeln("MAV error: %s" % msg)
                mpstate.status.mav_error += 1
609507
def time(ctx: Context, command: str):
    """"""
    with timer.Timing(verbose=True):
        proc = run(command, shell=True)
    ctx.exit(proc.returncode)
447262
def set_idle_params(self, timeout=None, exit=None):
        
        self._set('idle', timeout)
        self._set('die-on-idle', exit, cast=bool)

        return self._section
207570
private void elapsedTime(long startTime)
    {
        /** time elapsed in nanoseconds */
        long eta = System.nanoTime() - startTime;

        sessionState.out.print("Elapsed time: ");
        if (eta < 10000000)
        {
            sessionState.out.print(Math.round(eta/10000.0)/100.0);
        }
        else
        {
            sessionState.out.print(Math.round(eta/1000000.0));
        }
        sessionState.out.println(" msec(s).");
    }