// 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
The Express Workout Program
7giorni7 giorni
7step7 step
Tutti i partecipanti che avranno completato tutti gli step riceveranno un badge al termine del programma.
Info
No time? No problem. This workout program features a week’s worth of workouts, all less than 15 minutes long. Squeeze them in during your lunch break and do them almost anywhere.
Equipment required: Sturdy bed or chair, Kettlebell (optional)
Puoi anche partecipare a questo programma tramite l'app mobile. Vai all'App