diff --git a/modules/packages/NPBRandom.chpl b/modules/packages/NPBRandom.chpl index 36af9fe64883..603f6856e399 100644 --- a/modules/packages/NPBRandom.chpl +++ b/modules/packages/NPBRandom.chpl @@ -70,7 +70,7 @@ */ proc oddTimeSeed(): int(64) { use Time; - const seed = (timeSinceEpoch().totalSeconds()*1_000_000): int; + const seed = timeSinceEpoch().totalMicroseconds(); const oddseed = if seed % 2 == 0 then seed + 1 else seed; return oddseed; } diff --git a/modules/standard/Time.chpl b/modules/standard/Time.chpl index 400a9802ac9d..033e6dce59da 100644 --- a/modules/standard/Time.chpl +++ b/modules/standard/Time.chpl @@ -1746,6 +1746,17 @@ module Time { return days*(24*60*60) + seconds + microseconds / 1000000.0; } + /* Return the total number of milliseconds represented by this object */ + @unstable("'timeDelta.totalMilliseconds()' is unstable because it is new") + proc timeDelta.totalMilliseconds(): real { + return (days*(24*60*60) + seconds)*1000 + microseconds / 1000.0; + } + + /* Return the total number of microseconds represented by this object */ + @unstable("'timeDelta.totalMicroseconds()' is unstable because it is new") + proc timeDelta.totalMicroseconds(): int { + return (days*(24*60*60) + seconds)*1_000_000 + microseconds; + } /* Operators on timeDelta values */ diff --git a/test/library/standard/Time/dateTime/checkTotalMicro.chpl b/test/library/standard/Time/dateTime/checkTotalMicro.chpl new file mode 100644 index 000000000000..484ce29a0eac --- /dev/null +++ b/test/library/standard/Time/dateTime/checkTotalMicro.chpl @@ -0,0 +1,7 @@ +use Time; + +var a = new timeDelta(microseconds=10); +writeln(a.totalMicroseconds()); + +var b = new timeDelta(minutes=2, seconds=3); +writeln(b.totalMicroseconds()); diff --git a/test/library/standard/Time/dateTime/checkTotalMicro.good b/test/library/standard/Time/dateTime/checkTotalMicro.good new file mode 100644 index 000000000000..7a12a08f9684 --- /dev/null +++ b/test/library/standard/Time/dateTime/checkTotalMicro.good @@ -0,0 +1,2 @@ +10 +123000000 diff --git a/test/library/standard/Time/dateTime/checkTotalMilli.chpl b/test/library/standard/Time/dateTime/checkTotalMilli.chpl new file mode 100644 index 000000000000..8f124b324df0 --- /dev/null +++ b/test/library/standard/Time/dateTime/checkTotalMilli.chpl @@ -0,0 +1,7 @@ +use Time; + +var a = new timeDelta(milliseconds=10); +writeln(isClose(a.totalMilliseconds(), 10.0)); + +var b = new timeDelta(minutes=2, seconds=3); +writeln(isClose(b.totalMilliseconds(), 123000.0)); diff --git a/test/library/standard/Time/dateTime/checkTotalMilli.good b/test/library/standard/Time/dateTime/checkTotalMilli.good new file mode 100644 index 000000000000..bb101b641b9b --- /dev/null +++ b/test/library/standard/Time/dateTime/checkTotalMilli.good @@ -0,0 +1,2 @@ +true +true diff --git a/test/studies/ssca2/main/SSCA2_Modules/SSCA2_RMAT_graph_generator.chpl b/test/studies/ssca2/main/SSCA2_Modules/SSCA2_RMAT_graph_generator.chpl index ee6acf5b0550..a2feb696db59 100644 --- a/test/studies/ssca2/main/SSCA2_Modules/SSCA2_RMAT_graph_generator.chpl +++ b/test/studies/ssca2/main/SSCA2_Modules/SSCA2_RMAT_graph_generator.chpl @@ -167,7 +167,7 @@ proc Gen_RMAT_graph ( a : real, var rndPos = 1; const seed = if REPRODUCIBLE_PROBLEMS then 0556707007 - else (timeSinceEpoch().totalSeconds()*1_000_000+1):int; + else timeSinceEpoch().totalMicroseconds()+1; const delta = n_raw_edges + 1; // 1 corresponds to 'skip' in "old" code rndPos += 1; // start with a skip diff --git a/test/users/franzf/v0/chpl/main.chpl b/test/users/franzf/v0/chpl/main.chpl index 3c3e328368e7..db6c19ecc732 100644 --- a/test/users/franzf/v0/chpl/main.chpl +++ b/test/users/franzf/v0/chpl/main.chpl @@ -71,11 +71,11 @@ proc main() { } // benchmark computation - startTime = timeSinceEpoch().totalSeconds() * 1_000_000; + startTime = timeSinceEpoch().totalMicroseconds(); for i in 1..NUMRUNS { fft(N, Y, X); } - execTime = (timeSinceEpoch().totalSeconds()*1_000_000 - startTime)/NUMRUNS; + execTime = (timeSinceEpoch().totalMicroseconds() - startTime)/NUMRUNS; if (printTimings) then writeln("fft_", N, ": ", execTime, "us = ", ops / execTime, " Mflop/s"); else diff --git a/test/users/franzf/v1/chpl/main.chpl b/test/users/franzf/v1/chpl/main.chpl index 3fed186a66eb..120785ace8d1 100644 --- a/test/users/franzf/v1/chpl/main.chpl +++ b/test/users/franzf/v1/chpl/main.chpl @@ -71,11 +71,11 @@ proc main() { } // benchmark computation - startTime = timeSinceEpoch().totalSeconds()*1_000_000; + startTime = timeSinceEpoch().totalMicroseconds(); for i in 1..NUMRUNS { fft(N, Y, X); } - execTime = (timeSinceEpoch().totalSeconds()*1_000_000 - startTime)/NUMRUNS; + execTime = (timeSinceEpoch().totalMicroseconds() - startTime)/NUMRUNS; if (printTimings) then writeln("fft_", N, ": ", execTime, "us = ", ops / execTime, " Mflop/s"); else diff --git a/test/users/franzf/v2/chpl/main.chpl b/test/users/franzf/v2/chpl/main.chpl index 4345f585ef23..8ed4ec6db671 100644 --- a/test/users/franzf/v2/chpl/main.chpl +++ b/test/users/franzf/v2/chpl/main.chpl @@ -71,11 +71,11 @@ proc main() { } // benchmark computation - startTime = timeSinceEpoch().totalSeconds()*1_000_000; + startTime = timeSinceEpoch().totalMicroseconds(); for i in 1..NUMRUNS { fft(N, Y, X); } - execTime = (timeSinceEpoch().totalSeconds()*1_000_000 - startTime)/NUMRUNS; + execTime = (timeSinceEpoch().totalMicroseconds() - startTime)/NUMRUNS; if (printTimings) then writeln("fft_", N, ": ", execTime, "us = ", ops / execTime, " Mflop/s"); else