Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn cycles() -> i64 {
- unsafe {
- use core::arch::x86_64::_rdtsc;
- _rdtsc()
- }
- }
- fn main() {
- let start = cycles();
- let mut sum = 0;
- for x in 0..1000 {
- if x % 3 == 0 {
- sum += x;
- } else if x % 5 == 0 {
- sum += x;
- }
- }
- let end = cycles();
- println!("Duration: {} cycles", end - start);
- }
Add Comment
Please, Sign In to add comment