// Sample benchmarks to test which function is better for converting
// an integer into a string. First using the fmt.Sprintf function,
// then the strconv.FormatInt function and then strconv.Itoa.
package listing05_test
import (
"fmt"
"strconv"
"testing"
)
// BenchmarkSprintf provides performance numbers for the
// fmt.Sprintf function.
func BenchmarkSprintf(b *testing.B) {
number := 10
b.ResetTimer()
for i := 0; i < b.N; i++ {
fmt.Sprintf("%d", number)
}
}
// BenchmarkFormat provides performance numbers for the
// strconv.FormatInt function.
func BenchmarkFormat(b *testing.B) {
number := int64(10)
b.ResetTimer()
for i := 0; i < b.N; i++ {
strconv.FormatInt(number, 10)
}
}
// BenchmarkItoa provides performance numbers for the
// strconv.Itoa function.
func BenchmarkItoa(b *testing.B) {
number := 10
b.ResetTimer()
for i := 0; i < b.N; i++ {
strconv.Itoa(number)
}
}
$w
top of page
Dress To Impress
🧘♂️ Learn to Meditate
21Days21 Days
43passos43 passos
Tothom que hagi realitzat tots els passos obtindrà una insígnia quan acabi el programa.
Quant a
Need to bring some peace and calm to your life? Mindfulness and meditation are just what you need!!
Join this challenge to get a 21-day program introducing mindfulness and meditation. You get daily prompts explaining how to do sitting meditation plus mindfulness checks at the end of each day.
També pots unir-te al programa des de l'app mòbil. Ves a l'app