Trace functions running over/under the time.

@param  float|string $delta delta time
@param  bool         $over  TRUE = over the delta time, FALSE = under the delta time
546328
public function traceDeltaTime($delta, $over = true)
    {
        if (\is_string($delta)) {
            static $units = [
                'ns' => 1e-9,
                'us' => 1e-6,
                'ms' => 1e-3,
                's' => 1,
            ];

            foreach ($units as $unit => $multipler) {
                $length = \strlen($unit);
                if (\substr_compare($delta, $unit, -$length, $length, true) === 0) {
                    $delta = \substr($delta, 0, -$length) * $multipler;
                    break;
                }
            }
        }
        $delta = (float) $delta;

        $cb = function (\stdClass $record) use ($delta, $over) {
            if ($over) {
                if ($record->deltaTime < $delta) {
                    return self::SKIP;
                }
            }

            if ($record->deltaTime > $delta) {
                return self::SKIP;
            }

            return 0;
        };

        $this->setFilterCallback($cb, self::FILTER_EXIT);
    }
1325566
def delta(self):
        
        completed_date = parse_api_datetime(self.batch["CompletedDate"])
        created_date = parse_api_datetime(self.batch["CreatedDate"])
        td = completed_date - created_date
        return td.total_seconds()
340259
protected function trace()
    {
        foreach (\array_reverse($this->backtrace) as $stackFrame) {
            if ($this->isDebugCall($stackFrame)) {
                return $stackFrame;
            }
        }

        return \end($this->backtrace);
    }
409262
public static void dump(final Delta delta, final PrintStream out) {
        final List<Difference> sortedDifferences = new LinkedList<Difference>(delta.getDifferences());
        Collections.sort(sortedDifferences);
        dump(sortedDifferences, out);
    }
926366
def trace(function, *args, **k) :
	""""""

	if doTrace : print ("> "+function.__name__, args, k)
	result = function(*args, **k)
	if doTrace : print ("< "+function.__name__, args, k, "->", result)
	return result
875247
function trace() {
  if(!gruntRunner._trace) {
    return;
  }
  console.log('[grunt-runner](trace) ' + new Date().toISOString() + ' - ');
  console.log.apply(console, arguments);
  console.log('');
}
1366654
def dt_delta(dt, delta):
    
    delta_time = datetime.timedelta(days=delta)
    target_date = dt + delta_time
    return target_date
590989
public function traceEnd(): void
    {
        $now = microtime(true);
        foreach ($this->buffTrace as &$traceItem) {
            if ('' === $traceItem['result']) {
                $traceItem['time'] = $now - $traceItem['time'];
                $traceItem['result'] = 'Trace end';
            }
        }
        unset($traceItem);
    }
559778
public function review($completion, $mark = true) {
        // If current time is past timeend
        if ($this->timeend && $this->timeend < time()) {
            if ($mark) {
                $completion->mark_complete();
            }

            return true;
        }
        return false;
    }
503950
public long getAndAdd(T obj, long delta) {
        long prev, next;
        do {
            prev = get(obj);
            next = prev + delta;
        } while (!compareAndSet(obj, prev, next));
        return prev;
    }
446953
def monitor_counters(mc, output, counters, detailed, f):
    """"""
    # Print CSV header
    output.write("time,{}{}\n".format("x,y," if detailed else "",
                                      ",".join(counters)))

    system_info = mc.get_system_info()

    # Make an initial sample of the counters
    last_counter_values = sample_counters(mc, system_info)

    start_time = time.time()

    for _ in f():
        # Snapshot the change in counter values
        counter_values = sample_counters(mc, system_info)
        delta = deltas(last_counter_values, counter_values)
        last_counter_values = counter_values

        now = time.time() - start_time

        # Output the changes
        if detailed:
            for x, y in sorted(system_info):
                output.write("{:0.1f},{},{},{}\n".format(
                    now, x, y,
                    ",".join(str(getattr(delta[(x, y)], c))
                             for c in counters)))
        else:
            totals = [0 for _ in counters]
            for xy in sorted(system_info):
                for i, counter in enumerate(counters):
                    totals[i] += getattr(delta[xy], counter)
            output.write("{:0.1f},{}\n".format(
                now, ",".join(map(str, totals))))
829143
def _time_ym_delta(timestamp, delta, months):
    
    timestamp = list(time.localtime(timestamp))
    timestamp[int(months)] += delta
    return time.mktime(timestamp)
264585
public static function setIsDebug(bool $bool): void
    {
        if (self::isCliApp()) {
            self::$IS_DEBUG = $bool;
        } else {
            MSession::set(MCoreApplication::DEBUG, $bool);
        }
    }
1018973
public boolean recordOverride() {
    if (!currentInfo.isOverride()) {
      currentInfo.setOverride(true);
      populated = true;
      return true;
    } else {
      return false;
    }
  }
23
public static function trace($trace = null, $addObject = false)
    {
        if (!self::isDebug()) {
            return false;
        }

        $_this = self::i();

        $trace = $trace ? $trace : debug_backtrace($addObject);
        unset($trace[0]);

        $result = $_this->convertTrace($trace, $addObject);

        return $_this->dump($result, '! backtrace !');
    }
1018461
public static void main(String[] args) {
		for (int round = 1; round <= 5; round++) {
			Map<Long, Integer> deltaMsCount = new TreeMap<>();
			Map<Long, Integer> deltaNsCount = new TreeMap<>();
			System.out.println("\nRound: " + round);
			long msChanges = 0;
			long nsChanges = 0;

			long initMs = System.currentTimeMillis();
			long initNs = System.nanoTime();

			long ms = initMs;
			long ns = initNs;
			for (int i = 0; i < LOOP; i++) {
				long newMs = System.currentTimeMillis();
				long newNs = System.nanoTime();
				if (newMs != ms) {
					long delta = newMs - ms;
					Integer count = deltaMsCount.get(delta);
					if (count == null) {
						count = 0;
					}
					deltaMsCount.put(delta, ++count);
					msChanges++;
				}
				if (newNs != ns) {
					long delta = newNs - ns;
					Integer count = deltaNsCount.get(delta);
					if (count == null) {
						count = 0;
					}
					deltaNsCount.put(delta, ++count);
					nsChanges++;
				}
				ms = newMs;
				ns = newNs;
			}
			System.out.println("msChanges: " + msChanges + " during " + (System.currentTimeMillis() - initMs) + " ms");
			System.out.println("deltaMsCount = " + deltaMsCount);
			System.out.println("nsChanges: " + nsChanges + " during " + (System.nanoTime() - initNs) + " ns");
			System.out.println("deltaNsCount = " + deltaNsCount);

			// now something else...
			long msCount = 0;
			initMs = System.currentTimeMillis();
			while (true) {
				long newMs = System.currentTimeMillis();
				msCount++;
				if (newMs - initMs >= MS_RUN) {
					break;
				}
			}
			System.out.println("currentTimeMillis msCount = " + msCount);

			long nsCount = 0;
			initMs = System.nanoTime() / 1000000;
			while (true) {
				long newMs = System.nanoTime() / 1000000;
				nsCount++;
				if (newMs - initMs >= MS_RUN) {
					break;
				}
			}
			System.out.println("nanoTime msCount = " + nsCount);
			System.out.println("Ratio ms/ns: " + msCount / (double) nsCount);
		}

		for (int round = 1; round <= LOOP; round++) {
			long ns1 = System.nanoTime();
			long ns2 = System.nanoTime();
			long ns3 = System.nanoTime();
			long ns4 = System.nanoTime();
			long ns5 = System.nanoTime();
			if (round % (LOOP / 5) == 0) {
				System.out.println("\nns1 = " + ns1);
				System.out.println("ns2 = " + ns2 + " (diff: " + (ns2 - ns1) + ")");
				System.out.println("ns3 = " + ns3 + " (diff: " + (ns3 - ns2) + ")");
				System.out.println("ns4 = " + ns4 + " (diff: " + (ns4 - ns3) + ")");
				System.out.println("ns5 = " + ns5 + " (diff: " + (ns5 - ns4) + ")");
			}
		}

		System.out.println();

		// last thing - we will count how many nanoTimes in a row will have the same value
		for (int round = 1; round <= LOOP; round++) {
			long val = System.nanoTime();
			int count = 1;
			while (val == System.nanoTime()) {
				count++;
			}
			if (round % (LOOP / 5) == 0) {
				System.out.println("Change after " + count + " calls");
			}
		}
	}
267239
public function markChanged(): void
    {
        $this->changed = true;
        $this->xliff->setDate(new \DateTime());
        if (!$this->buffering) {
            $this->xliff->save($this->filename);
        }
    }