Java Code Examples for com.google.protobuf.util.Timestamps#between()
The following examples show how to use
com.google.protobuf.util.Timestamps#between() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PutOperationStage.java From bazel-buildfarm with Apache License 2.0 | 6 votes |
private void removeStaleData(Timestamp now) { // currentSlot != lastUsedSlot means stepping over to a new bucket. // The data in the new bucket should be thrown away before storing new data. int currentSlot = getCurrentSlot(now); if (lastOperationCompleteTime != null && lastUsedSlot >= 0) { Duration duration = Timestamps.between(lastOperationCompleteTime, now); // if 1) duration between the new added operation and last added one is longer than period // or 2) the duration is shorter than period but longer than time range of a single bucket // and at the same time currentSlot == lastUsedSlot if ((Durations.toMillis(duration) >= Durations.toMillis(period)) || (lastUsedSlot == currentSlot && Durations.toMillis(duration) > (Durations.toMillis(period) / buckets.length))) { for (OperationStageDurations bucket : buckets) { bucket.reset(); } } else if (lastUsedSlot != currentSlot) { // currentSlot < lastUsedSlot means wrap around happened currentSlot = currentSlot < lastUsedSlot ? currentSlot + NumOfSlots : currentSlot; for (int i = lastUsedSlot + 1; i <= currentSlot; i++) { buckets[i % buckets.length].reset(); } } } }
Example 2
Source File: PutOperationStage.java From bazel-buildfarm with Apache License 2.0 | 6 votes |
void set(ExecutedActionMetadata metadata) { queuedToMatch = Timestamps.between(metadata.getQueuedTimestamp(), metadata.getWorkerStartTimestamp()); matchToInputFetchStart = Timestamps.between( metadata.getWorkerStartTimestamp(), metadata.getInputFetchStartTimestamp()); inputFetchStartToComplete = Timestamps.between( metadata.getInputFetchStartTimestamp(), metadata.getInputFetchCompletedTimestamp()); inputFetchCompleteToExecutionStart = Timestamps.between( metadata.getInputFetchCompletedTimestamp(), metadata.getExecutionStartTimestamp()); executionStartToComplete = Timestamps.between( metadata.getExecutionStartTimestamp(), metadata.getExecutionCompletedTimestamp()); executionCompleteToOutputUploadStart = Timestamps.between( metadata.getExecutionCompletedTimestamp(), metadata.getOutputUploadStartTimestamp()); outputUploadStartToComplete = Timestamps.between( metadata.getOutputUploadStartTimestamp(), metadata.getOutputUploadCompletedTimestamp()); operationCount = 1; }
Example 3
Source File: PutOperationStage.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
private static float millisecondBetween(Timestamp from, Timestamp to) { // The time unit we want is millisecond. // 1 second = 1000 milliseconds // 1 millisecond = 1000,000 nanoseconds Duration d = Timestamps.between(from, to); return d.getSeconds() * 1000.0f + d.getNanos() / (1000.0f * 1000.0f); }
Example 4
Source File: RemoteExecutionEventListener.java From buck with Apache License 2.0 | 5 votes |
/** Event specific subscriber method. */ @Subscribe public void onActionEventTerminal(RemoteExecutionActionEvent.Terminal event) { hasFirstRemoteActionStarted.set(true); getStateCount(State.WAITING).decrement(); getStateCount(event.getState()).increment(); if (event.getExecutedActionMetadata().isPresent()) { ExecutedActionInfo executedActionInfo = event.getRemoteExecutionMetadata().get().getExecutedActionInfo(); remoteCpuTimeMs.add(TimeUnit.MICROSECONDS.toMillis(executedActionInfo.getCpuStatUsageUsec())); Duration queueDuration = Timestamps.between( event.getExecutedActionMetadata().get().getQueuedTimestamp(), event.getExecutedActionMetadata().get().getWorkerStartTimestamp()); remoteQueueTimeMs.add( TimeUnit.SECONDS.toMillis(queueDuration.getSeconds()) + TimeUnit.NANOSECONDS.toMillis(queueDuration.getNanos())); Duration totalDuration = Timestamps.between( event.getExecutedActionMetadata().get().getWorkerStartTimestamp(), event.getExecutedActionMetadata().get().getWorkerCompletedTimestamp()); totalRemoteTimeMs.add( TimeUnit.SECONDS.toMillis(totalDuration.getSeconds()) + TimeUnit.NANOSECONDS.toMillis(totalDuration.getNanos())); } }
Example 5
Source File: JavaLoadtestWorker.java From pubsub with Apache License 2.0 | 4 votes |
private Duration getTimeSinceStart() { return Timestamps.between(startTime, Timestamps.fromMillis(System.currentTimeMillis())); }