Merge "Compute time differences with Duration"

This commit is contained in:
Jonathan Tan 2020-10-19 12:25:57 -04:00 committed by Gerrit Code Review @ Eclipse.org
commit de914b7caf
1 changed files with 12 additions and 9 deletions

View File

@ -42,6 +42,8 @@
import java.io.OutputStream; import java.io.OutputStream;
import java.io.UncheckedIOException; import java.io.UncheckedIOException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -1008,7 +1010,7 @@ else if (requestValidator instanceof AnyRequestValidator)
else else
advertised = refIdSet(getAdvertisedOrDefaultRefs().values()); advertised = refIdSet(getAdvertisedOrDefaultRefs().values());
long negotiateStart = System.currentTimeMillis(); Instant negotiateStart = Instant.now();
accumulator.advertised = advertised.size(); accumulator.advertised = advertised.size();
ProtocolV0Parser parser = new ProtocolV0Parser(transferConfig); ProtocolV0Parser parser = new ProtocolV0Parser(transferConfig);
@ -1050,8 +1052,8 @@ else if (requestValidator instanceof AnyRequestValidator)
if (!req.getClientShallowCommits().isEmpty()) if (!req.getClientShallowCommits().isEmpty())
walk.assumeShallow(req.getClientShallowCommits()); walk.assumeShallow(req.getClientShallowCommits());
sendPack = negotiate(req, accumulator, pckOut); sendPack = negotiate(req, accumulator, pckOut);
accumulator.timeNegotiating += System.currentTimeMillis() accumulator.timeNegotiating = Duration
- negotiateStart; .between(negotiateStart, Instant.now()).toMillis();
if (sendPack && !biDirectionalPipe) { if (sendPack && !biDirectionalPipe) {
// Ensure the request was fully consumed. Any remaining input must // Ensure the request was fully consumed. Any remaining input must
@ -1138,7 +1140,7 @@ private void fetchV2(PacketLineOut pckOut) throws IOException {
} }
PackStatistics.Accumulator accumulator = new PackStatistics.Accumulator(); PackStatistics.Accumulator accumulator = new PackStatistics.Accumulator();
long negotiateStart = System.currentTimeMillis(); Instant negotiateStart = Instant.now();
ProtocolV2Parser parser = new ProtocolV2Parser(transferConfig); ProtocolV2Parser parser = new ProtocolV2Parser(transferConfig);
FetchV2Request req = parser.parseFetchRequest(pckIn); FetchV2Request req = parser.parseFetchRequest(pckIn);
@ -1244,8 +1246,8 @@ private void fetchV2(PacketLineOut pckOut) throws IOException {
pckOut.writeString("packfile\n"); //$NON-NLS-1$ pckOut.writeString("packfile\n"); //$NON-NLS-1$
} }
accumulator.timeNegotiating = System.currentTimeMillis() accumulator.timeNegotiating = Duration
- negotiateStart; .between(negotiateStart, Instant.now()).toMillis();
sendPack(accumulator, sendPack(accumulator,
req, req,
@ -1795,12 +1797,13 @@ private void parseWants(PackStatistics.Accumulator accumulator) throws IOExcepti
if (notAdvertisedWants != null) { if (notAdvertisedWants != null) {
accumulator.notAdvertisedWants = notAdvertisedWants.size(); accumulator.notAdvertisedWants = notAdvertisedWants.size();
long startReachabilityChecking = System.currentTimeMillis(); Instant startReachabilityChecking = Instant.now();
requestValidator.checkWants(this, notAdvertisedWants); requestValidator.checkWants(this, notAdvertisedWants);
accumulator.reachabilityCheckDuration = System.currentTimeMillis() - accumulator.reachabilityCheckDuration = Duration
startReachabilityChecking; .between(startReachabilityChecking, Instant.now())
.toMillis();
} }
AsyncRevObjectQueue q = walk.parseAny(wantIds, true); AsyncRevObjectQueue q = walk.parseAny(wantIds, true);