Last active
May 9, 2021 21:27
-
-
Save deepch/c107be54ee81100cf28292f4a611fb0a to your computer and use it in GitHub Desktop.
main.go
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
package main | |
import ( | |
"log" | |
"time" | |
) | |
const ( | |
Success = "Success" | |
Copy = "Copy" | |
Link = "Link" | |
) | |
/* | |
Array golang speed test use link range | |
2021/05/10 00:24:30 Copy 9.591µs | |
2021/05/10 00:24:30 Link 8.768µs | |
2021/05/10 00:24:30 Copy 9.579µs | |
2021/05/10 00:24:30 Link 8.796µs | |
2021/05/10 00:24:30 Copy 9.579µs | |
2021/05/10 00:24:30 Link 8.79µs | |
2021/05/10 00:24:30 Copy 9.606µs | |
2021/05/10 00:24:30 Link 8.769µs | |
2021/05/10 00:24:30 Copy 9.579µs | |
2021/05/10 00:24:30 Link 8.794µs | |
2021/05/10 00:24:30 Copy 9.571µs | |
2021/05/10 00:24:30 Link 8.779µs | |
2021/05/10 00:24:30 Copy 9.604µs | |
*/ | |
func main() { | |
array := [40960]byte{} | |
array[55] = 9 | |
for i := 0; i < 100; i++ { | |
stime := time.Now() | |
for b := range &array { | |
if array[b] == 9 { | |
// log.Println(Success) | |
} | |
} | |
log.Println(Link, time.Since(stime)) | |
stime = time.Now() | |
for _, b := range array { | |
if b == 9 { | |
// log.Println(Success) | |
} | |
} | |
log.Println(Copy, time.Since(stime)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment