Elapsed time of entire execution, summed over all executions, for all the threads,
that executed the kernel on this device.
346493
public double getCumulativeElapsedTimeAllGlobal() {
	  final long[] accumulatedTimesHolder = new long[NUM_EVENTS];
	  globalAcc.consultAccumulatedTimes(accumulatedTimesHolder);

      double sum = 0;
      for (int i = 1; i <= ProfilingEvent.EXECUTED.ordinal(); ++i) {
         sum += accumulatedTimesHolder[i];
      }
      return sum;
   }
1263447
public static void completeBackgroundTasks(long timeoutMillis) {
        
        boolean fifoEmpty = false;
        boolean asyncThreadsCompleted = false;
        
        long absTimeout = System.currentTimeMillis() + timeoutMillis;
        while (System.currentTimeMillis() < absTimeout) {
            synchronized (fifo) {
                fifoEmpty = (fifo.size() == 0);
            }
            
            synchronized (JGoogleAnalyticsTracker.class) {
                asyncThreadsCompleted = (asyncThreadsRunning == 0);
            }
            
            if (fifoEmpty && asyncThreadsCompleted) {
                break;
            }
            
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                break;
            }
        }
    }
189675
public synchronized boolean getThreadCpuTimes(int pid, long[] result) {
        int rc = GetThreadTimes(pid, callBuf);
        if (rc == 0) {
            long ktime = (0xFFFFFFFFl & callBuf[4]) | ((long)callBuf[5]) << 32;
            long utime = (0xFFFFFFFFl & callBuf[6]) | ((long)callBuf[7]) << 32;
            
            result[0] = ktime / 10;
            result[1] = utime / 10;
            return true;
        }
        else {
            System.out.println("Error code: " + rc);
            return false;
        }
    }
602337
public long getElapsedMilliseconds() {
		long elapsed;
		if (running) {
			elapsed = (System.nanoTime() - startTime);
		} else {
			elapsed = (stopTime - startTime);
		}
		return elapsed / nsPerMs;
	}
733826
@Benchmark
  @BenchmarkMode(Mode.SampleTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public void manyRunnables() throws Exception {
    incrRunnable.val = 0;
    for (int i = 0; i < 500; i++) {
      executor.execute(incrRunnable);
    }
    executor.execute(phaserRunnable);
    phaser.arriveAndAwaitAdvance();
    if (incrRunnable.val != 500) {
      throw new AssertionError();
    }
  }
908709
private static function execution_time(){
        if (self::$execution_time === 0){
            self::$execution_time = -microtime(true);
        }else{
            self::$execution_time += microtime(true);
        }
        return self::$execution_time;
    }
1237782
def kernel():
	
	print('================================')
	print('  WARNING: upgrading the kernel')
	print('================================')
	time.sleep(5)

	print('-[kernel]----------')
	cmd('rpi-update', True)
	print(' >> You MUST reboot to load the new kernel <<')
1301285
public long getElapsedSeconds() {
		long elapsed;
		if (running) {
			elapsed = (System.nanoTime() - startTime);
		} else {
			elapsed = (stopTime - startTime);
		}
		return elapsed / nsPerSs;
	}
1190056
def get_memory_info(self) -> str:
        ''''''
        output, _ = self._execute(
            '-s', self.device_sn, 'shell', 'cat', '/proc/meminfo')
        return output
1086033
static double run(int num_threads) {

    final double membw[] = new double[num_threads];
    Thread[] threads = new Thread[num_threads];
    for (int t=0;t<num_threads;++t) {
      final int thread_num = t;
      threads[t] = new Thread() {
        public void run() {
          MemoryBandwidth l = new MemoryBandwidth();
          membw[thread_num] = l.run_benchmark();
        }
      };
    }
    for (int t=0;t<num_threads;++t) {
      threads[t].start();
    }
    for (int t=0;t<num_threads;++t) {
      try {
        threads[t].join();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
    return Utils.sum(membw);
  }
965232
@Override
    public void aggregate(Aggregate op, long key) {
        int deviceId = Nd4j.getAffinityManager().getDeviceForCurrentThread();
        if (opCounter.get() == null)
            opCounter.set(new AtomicLong(0));

        // we enqueue op for specific device here
        aggregates.get(deviceId).add(new AggregateDescriptor(op, key, opCounter.get().getAndIncrement()));
    }
816016
public void printThreadCpuUsages(OutputStream out, CpuUsageComparator cmp) {
    final PrintWriter writer = getPrintWriter(out);
    final Map<String, Object> threadCpuUsages = getThreadCpuUsages(cmp);

    writer.printf("Time: %s%n%n", new Date((Long) threadCpuUsages.get(CURRENT_TIME)));
    final long uptimeMillis = (Long) threadCpuUsages.get(UPTIME_MS);
    final long uptimeNanos = TimeUnit.NANOSECONDS.convert(uptimeMillis, TimeUnit.MILLISECONDS);
    writer.printf("Uptime: %s%n%n", toDuration(uptimeNanos));

    @SuppressWarnings("unchecked")
    final Map<String, Long> jvmUsageTime = (Map<String, Long>)
        threadCpuUsages.get(JVM_USAGE_TIME);
    writer.println("JVM Usage Time: ");
    writer.printf("%11s %11s %11s %11s   %7s   %s%n",
        "1-min", "5-min", "15-min", "overall", "id", "name");
    writer.printf("%11s %11s %11s %11s   %7s   %s%n",
        toDuration(jvmUsageTime.get(ONE_MIN)),
        toDuration(jvmUsageTime.get(FIVE_MIN)),
        toDuration(jvmUsageTime.get(FIFTEEN_MIN)),
        toDuration(jvmUsageTime.get(OVERALL)),
        "-",
        "jvm");
    writer.println();

    @SuppressWarnings("unchecked")
    final Map<String, Double> jvmUsagePerc =
        (Map<String, Double>) threadCpuUsages.get(JVM_USAGE_PERCENT);
    writer.println("JVM Usage Percent: ");
    writer.printf("%11s %11s %11s %11s   %7s   %s%n",
        "1-min", "5-min", "15-min", "overall", "id", "name");
    writer.printf("%10.2f%% %10.2f%% %10.2f%% %10.2f%%   %7s   %s%n",
        jvmUsagePerc.get(ONE_MIN),
        jvmUsagePerc.get(FIVE_MIN),
        jvmUsagePerc.get(FIFTEEN_MIN),
        jvmUsagePerc.get(OVERALL),
        "-",
        "jvm");
    writer.println();

    writer.println("Breakdown by thread (100% = total cpu usage for jvm):");
    writer.printf("%11s %11s %11s %11s   %7s   %s%n",
        "1-min", "5-min", "15-min", "overall", "id", "name");
    @SuppressWarnings("unchecked")
    List<Map<String, Object>> threads =
        (List<Map<String, Object>>) threadCpuUsages.get(THREADS);
    for (Map<String, Object> thread : threads) {
      writer.printf("%10.2f%% %10.2f%% %10.2f%% %10.2f%%   %7d   %s%n",
          thread.get(ONE_MIN),
          thread.get(FIVE_MIN),
          thread.get(FIFTEEN_MIN),
          thread.get(OVERALL),
          thread.get(ID),
          thread.get(NAME));
    }
    writer.println();
    writer.flush();
  }
794313
def _timed_process(self, *args, **kwargs):
        """"""
        for processor in self._processors:
            start_time = _time.process_time()
            processor.process(*args, **kwargs)
            process_time = int(round((_time.process_time() - start_time) * 1000, 2))
            self.process_times[processor.__class__.__name__] = process_time
1098980
protected void addPropertiesProcessingTime() {

    HashMap<String, Long> mapComponentTimes			= new HashMap<>();
    HashMap<String, Long> mapComponentInvocations	= new HashMap<>();

    // For multi-threaded transaction: will calculate the sum of the time spent by all components in all threads
    if (this.componentsMultiThread != null) {
      for (Component component : this.componentsMultiThread.getComponents()) {
        addTimePerComponent(mapComponentTimes, component);
        addInvocationPerComponent(mapComponentInvocations, component);
      }
    }

    for (Component component : this.components.values()) {
      addTimePerComponent(mapComponentTimes, component);
    }

    for (Entry<String, Long> entry : mapComponentTimes.entrySet()) {
      putProperty(entry.getKey(), addDuration(entry.getValue()));
    }

    for (Entry<String, Long> entry : mapComponentInvocations.entrySet()) {
      putProperty(entry.getKey(), entry.getValue().toString());
    }
    putProperty(TOTAL_COMPONENT, addDuration(this.total.getTime()));
  }
510436
public void run() {
        try {
            while (--expires >= 0) {
                sleep(sysInterval);
                synchronized (ThreadClockImpl.class) {
                    currentTimeMillis += sysInterval;
                }
            }
        } catch (InterruptedException e) {
            System.out.println("Clock thread interrupted");
        }
    }
403197
@Override
    public void touch() {
        if (index.get() == null) {
            // set index
            int numDevces = Nd4j.getAffinityManager().getNumberOfDevices();

            /*
                if we have > 1 computational device, we assign workers to workspaces "as is", as provided via AffinityManager
             */
            if (numDevces > 1 && parties > 1) {
                int localIndex = Nd4j.getAffinityManager().getDeviceForCurrentThread();

                index.set(localIndex);
            } else {
                // if we have only 1 device (like cpu system, or single gpu), just attach consumer via flat index
                index.set(workersCounter.getAndIncrement());
            }
        }
    }
560200
@Override
    public void attachThreadToDevice(long threadId, Integer deviceId) {
        val t = Thread.currentThread();
        String name = "N/A";
        if (t.getId() == threadId)
            name = t.getName();

        List<Integer> devices = new ArrayList<>(CudaEnvironment.getInstance().getConfiguration().getAvailableDevices());
        logger.trace("Manually mapping thread [{} - {}] to device [{}], out of [{}] devices...", threadId,
                name, deviceId, devices.size());
        affinityMap.put(threadId, deviceId);
    }