-
-
Save slaperche-zenly/21f59b36dc954b20295193ed8bba464d to your computer and use it in GitHub Desktop.
Compare the execution time with a mix of valid and invalid values.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::time::Instant; | |
fn main() { | |
let mut valid = 0; | |
let start = Instant::now(); | |
for i in 0..=0x7fff_ffff_u32 { | |
let cell = 0x0880_0000_001f_ffff | (u64::from(i) << 21); | |
let is_valid = h3cell::is_valid_h3(cell); | |
valid += is_valid as usize; | |
} | |
let duration = start.elapsed(); | |
println!("found {} valid cells in {:?}", valid, duration); | |
let mut valid = 0; | |
let start = Instant::now(); | |
for i in 0..=0x7fff_ffff_u32 { | |
let cell = 0x0880_0000_001f_ffff | (u64::from(i) << 21); | |
let is_valid = unsafe { h3ron_h3_sys::h3IsValid(cell) != 0 }; | |
valid += is_valid as usize; | |
} | |
let duration = start.elapsed(); | |
println!("found {} valid cells in {:?}", valid, duration); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment