// 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
Zone Workout
8jours8 jours
9étapes9 étapes
Les participants qui ont complété toutes les étapes du programme recevront un badge.
À propos
Zone Workout is a 20-day intensive exercise program designed to push your limits and transform your fitness. Each day, you'll engage in grueling workouts that challenge your strength, endurance, and determination. Whether you're looking to build muscle, lose weight, or simply improve your overall fitness, this program will help you achieve your goals. Get ready to sweat, push your boundaries, and see real results!
Vous pouvez également rejoindre ce programme via l'appli mobile. Aller sur l'appli