rust-rustc-test-Update-for-new-time.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. From 22fce08bf4837ac369e5d37ec3e3e31850f4c1d5 Mon Sep 17 00:00:00 2001
  2. From: Maxime Devos <maximedevos@telenet.be>
  3. Date: Mon, 12 Sep 2022 20:28:56 +0200
  4. Subject: [PATCH] Update to rust-time@0.3.11.
  5. The benchmarks and tests fail to compile, though this seems unrelated
  6. to the time update.
  7. Upstream: <https://github.com/servo/rustc-test/pull/16>
  8. ---
  9. Cargo.toml.orig | 3 ++-
  10. src/lib.rs | 14 ++++++++------
  11. 2 files changed, 10 insertions(+), 7 deletions(-)
  12. diff --git a/Cargo.toml.orig b/Cargo.toml.orig
  13. index 3a6b29c..18c65f6 100644
  14. --- a/Cargo.toml.orig
  15. +++ b/Cargo.toml.orig
  16. @@ -1,3 +1,4 @@
  17. +# Modified by Maxime Devos (see 4(b) of the Apache license)
  18. [package]
  19. name = "rustc-test"
  20. version = "0.3.1"
  21. @@ -15,7 +16,7 @@ libc = "0.2"
  22. getopts = "0.2"
  23. rustc-serialize = "0.3"
  24. term = "0.4"
  25. -time = "0.1"
  26. +time = "0.3"
  27. [build-dependencies]
  28. rustc_version = "0.2.1"
  29. diff --git a/src/lib.rs b/src/lib.rs
  30. index cf2a334..d901f06 100644
  31. --- a/src/lib.rs
  32. +++ b/src/lib.rs
  33. @@ -1,6 +1,7 @@
  34. // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
  35. // file at the top-level directory of this distribution and at
  36. // http://rust-lang.org/COPYRIGHT.
  37. +// Modified by Maxime Devos (see 4(b) of the Apache license)
  38. //
  39. // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
  40. // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
  41. @@ -40,11 +41,12 @@ use self::TestEvent::*;
  42. use self::NamePadding::*;
  43. use self::OutputLocation::*;
  44. -use time::{PreciseTime, Duration};
  45. +use time::{Instant, Duration};
  46. use std::any::Any;
  47. use std::cmp;
  48. use std::collections::BTreeMap;
  49. +use std::convert::TryInto;
  50. use std::env;
  51. use std::fmt;
  52. use std::fs::File;
  53. @@ -1259,16 +1261,16 @@ impl Bencher {
  54. pub fn iter<T, F>(&mut self, mut inner: F)
  55. where F: FnMut() -> T
  56. {
  57. - let start = PreciseTime::now();
  58. + let start = Instant::now();
  59. let k = self.iterations;
  60. for _ in 0..k {
  61. black_box(inner());
  62. }
  63. - self.dur = start.to(PreciseTime::now());
  64. + self.dur = Instant::now() - start;
  65. }
  66. pub fn ns_elapsed(&mut self) -> u64 {
  67. - self.dur.num_nanoseconds().unwrap() as u64
  68. + self.dur.whole_nanoseconds().try_into().unwrap()
  69. }
  70. pub fn ns_per_iter(&mut self) -> u64 {
  71. @@ -1313,7 +1315,7 @@ impl Bencher {
  72. let mut total_run = Duration::seconds(0);
  73. let samples: &mut [f64] = &mut [0.0_f64; 50];
  74. loop {
  75. - let loop_start = PreciseTime::now();
  76. + let loop_start = Instant::now();
  77. for p in &mut *samples {
  78. self.bench_n(n, |x| f(x));
  79. @@ -1330,7 +1332,7 @@ impl Bencher {
  80. stats::winsorize(samples, 5.0);
  81. let summ5 = stats::Summary::new(samples);
  82. - let loop_run = loop_start.to(PreciseTime::now());
  83. + let loop_run = Instant::now() - loop_start;
  84. // If we've run for 100ms and seem to have converged to a
  85. // stable median.
  86. base-commit: 1e824b584013e4acf02fcd404ca33580c2bc3478
  87. --
  88. 2.37.3