8339486: JFR: Modernize
Reviewed-by: mgronlun
This commit is contained in:
parent
4e2dde2f0d
commit
e25a9e7fd8
src/jdk.jfr/share/classes/jdk/jfr/internal
test/jdk/jdk/jfr
api
event
recording
event/runtime
@ -657,7 +657,7 @@ public final class PlatformRecorder {
|
||||
}
|
||||
target.setStartTime(startTime);
|
||||
target.setStopTime(endTime);
|
||||
target.setInternalDuration(Duration.between(startTime, endTime));
|
||||
target.setInternalDuration(startTime.until(endTime));
|
||||
}
|
||||
|
||||
public synchronized void migrate(SafePath repo) throws IOException {
|
||||
|
@ -472,7 +472,7 @@ abstract class Function {
|
||||
if (last == null) {
|
||||
return ChronoUnit.FOREVER.getDuration();
|
||||
}
|
||||
return Duration.between(first, last);
|
||||
return first.until(last);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -62,7 +62,7 @@ public final class StopWatch {
|
||||
for (int i = 0; i < timings.size() - 1; i++) {
|
||||
Timing current = timings.get(i);
|
||||
Timing next = timings.get(i + 1);
|
||||
Duration d = Duration.between(current.start(), next.start());
|
||||
Duration d = current.start().until(next.start());
|
||||
sb.add(current.name() + "=" + ValueFormatter.formatDuration(d));
|
||||
}
|
||||
return sb.toString();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -87,7 +87,7 @@ public class TestGetDuration {
|
||||
Events.hasEvents(testEvents);
|
||||
for (RecordedEvent re : testEvents) {
|
||||
int id = re.getValue("id");
|
||||
Asserts.assertEquals(re.getDuration(), Duration.between(re.getStartTime(), re.getEndTime()));
|
||||
Asserts.assertEquals(re.getDuration(), re.getStartTime().until(re.getEndTime()));
|
||||
switch (id) {
|
||||
case DURATIONAL_EVENT_ID:
|
||||
Asserts.assertTrue(!re.getDuration().isNegative() && !re.getDuration().isZero());
|
||||
@ -111,7 +111,7 @@ public class TestGetDuration {
|
||||
List<RecordedEvent> recordedEvents = Events.fromRecording(r);
|
||||
Events.hasEvents(recordedEvents);
|
||||
for (RecordedEvent re : recordedEvents) {
|
||||
Asserts.assertEquals(re.getDuration(), Duration.between(re.getStartTime(), re.getEndTime()));
|
||||
Asserts.assertEquals(re.getDuration(), re.getStartTime().until(re.getEndTime()));
|
||||
switch (re.getEventType().getName()) {
|
||||
case EventNames.JVMInformation:
|
||||
Asserts.assertTrue(re.getDuration().isZero());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -88,7 +88,7 @@ public class TestGetStream {
|
||||
}
|
||||
|
||||
private static void printTimeStamp(String name, Instant t) {
|
||||
Duration s = Duration.between(offset, t);
|
||||
Duration s = offset.until(t);
|
||||
System.out.println(name + ": " + (s.getSeconds() * 1_000_000_000L + s.getNano()));
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -53,7 +53,7 @@ public class TestDuration {
|
||||
|
||||
Instant afterStop = Instant.now();
|
||||
Asserts.assertLessThanOrEqual(r.getStopTime(), afterStop, "getStopTime() > afterStop");
|
||||
long durationMillis = Duration.between(afterStart, r.getStopTime()).toMillis();
|
||||
long durationMillis = afterStart.until(r.getStopTime()).toMillis();
|
||||
|
||||
// Performance of test servers varies too much to make a strict check of actual duration.
|
||||
// We only check that recording stops before timeout of 20 seconds.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -55,7 +55,7 @@ public class TestStateDuration {
|
||||
System.out.println("Waiting for recording to reach STOPPED state");
|
||||
CommonHelper.waitForRecordingState(r, RecordingState.STOPPED);
|
||||
Instant stop = Instant.now();
|
||||
Duration measuredDuration = Duration.between(start, stop);
|
||||
Duration measuredDuration = start.until(stop);
|
||||
System.out.println("Recording stopped at " + stop + ". Measured duration " + measuredDuration);
|
||||
// Timer task uses System.currentMillis, and java.time uses other source.
|
||||
Duration deltaDueToClockNotInSync = Duration.ofMillis(100);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -55,7 +55,7 @@ public class TestStateScheduleStart {
|
||||
// Test servers vary too much in performance to make an accurate check.
|
||||
// We only check that we don't time out after 20 seconds.
|
||||
Instant started = Instant.now();
|
||||
long millis = Duration.between(start, started).toMillis();
|
||||
long millis = start.until(started).toMillis();
|
||||
System.out.println("Recording started at " + started + ". Delta millis=" + millis + ", expected about 2000");
|
||||
|
||||
verifyIllegalState(() -> r.start(), "double start()");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -93,7 +93,7 @@ public class TestThreadCpuTimeEvent {
|
||||
barrier.await();
|
||||
Instant start = Instant.now();
|
||||
counter = 0;
|
||||
while ((Duration.between(start, Instant.now()).compareTo(runTime) < 0) ||
|
||||
while ((start.until(Instant.now()).compareTo(runTime) < 0) ||
|
||||
(counter < cpuConsumerMinCount)) {
|
||||
counter++;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user