// 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
Sugar Reset 🚫🍫
5656 undefined
7070 undefined
オンラインプログラムが終了した時に、すべてのステップを完了した参加者にバッジが授与されます。
詳細
Want to feel better, have more energy and trim down your waistline at the same time? Removing refined and added sugar from your diet is for you!
There’s no need to count calories or ever be hungry. Instead focus on naturally filling and nourishing foods.
Get the encouragement you need to give up your sweet tooth, plus some ideas for healthy alternatives.