@@ -18,25 +18,37 @@ pub fn bench_runtime(rustc: &str, id: Option<&str>, benchmark_dir: PathBuf) -> a
18
18
for binary in binaries {
19
19
let name = binary. path . file_name ( ) . and_then ( |s| s. to_str ( ) ) . unwrap ( ) ;
20
20
21
- let result = Command :: new ( & binary. path ) . arg ( "benchmark" ) . output ( ) ?;
22
- if !result. status . success ( ) {
23
- anyhow:: bail!(
24
- "Failed to run runtime benchmark {name}\n {}\n {}" ,
25
- String :: from_utf8_lossy( & result. stdout) ,
26
- String :: from_utf8_lossy( & result. stderr)
27
- ) ;
28
- } else {
29
- log:: info!( "Successfully ran runtime benchmark {name}" , ) ;
30
-
31
- let data: Vec < BenchmarkResult > = serde_json:: from_slice ( & result. stdout ) ?;
32
- // TODO: do something with the result
33
- println ! ( "{name}: {:?}" , data) ;
34
- }
21
+ let data: Vec < BenchmarkResult > = execute_runtime_binary ( & binary. path , name) ?;
22
+ // TODO: do something with the result
23
+ println ! ( "{name}: {:?}" , data) ;
35
24
}
36
25
37
26
Ok ( ( ) )
38
27
}
39
28
29
+ fn execute_runtime_binary ( binary : & Path , name : & str ) -> anyhow:: Result < Vec < BenchmarkResult > > {
30
+ // Turn off ASLR
31
+ let mut command = Command :: new ( "setarch" ) ;
32
+ command. arg ( std:: env:: consts:: ARCH ) ;
33
+ command. arg ( "-R" ) ;
34
+ command. arg ( binary) ;
35
+ command. arg ( "benchmark" ) ;
36
+
37
+ let result = command. output ( ) ?;
38
+
39
+ if !result. status . success ( ) {
40
+ return Err ( anyhow:: anyhow!(
41
+ "Failed to run runtime benchmark {name}\n {}\n {}" ,
42
+ String :: from_utf8_lossy( & result. stdout) ,
43
+ String :: from_utf8_lossy( & result. stderr)
44
+ ) ) ;
45
+ }
46
+
47
+ log:: info!( "Successfully ran runtime benchmark {name}" ) ;
48
+
49
+ Ok ( serde_json:: from_slice ( & result. stdout ) ?)
50
+ }
51
+
40
52
/// Compiles all runtime benchmarks and returns the stdout output of Cargo.
41
53
fn compile_runtime_benchmarks ( toolchain : & LocalToolchain , dir : & Path ) -> anyhow:: Result < Vec < u8 > > {
42
54
let result = Command :: new ( & toolchain. cargo )
0 commit comments