Skip to content

Instantly share code, notes, and snippets.

@zerkms
Last active September 13, 2019 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerkms/40e1ac1378495490b9c8f5d49d40cbe0 to your computer and use it in GitHub Desktop.
Save zerkms/40e1ac1378495490b9c8f5d49d40cbe0 to your computer and use it in GitHub Desktop.
package bb
import (
"strings"
"testing"
)
var str = `well they might wear classic reeboks
or knackered converse
or tracky bottoms tucked in socks
but all of that's what the point is not
the point is there ain't no romance around there
but that's the truth that they can't see
they probably like to throw a punch at me and
if you could only see them then you would agree
agree that there ain't no romance around there
you know oh it's a funny thing you know
tell them if you like
tell them all tonight they'll never listen
cos their minds are made up
and of cos it's all okay
to carry on that way
over there there's broken bones
there's only music so that there's new ringtones
it doesn't take no sherlock holmes
to see it's a little different around here
don't get me wrong notice boys in bands
and kids who like to scrape with pool cues in their hands
just because they've had a coupla cans
they think it's alright to act like a dickhead`
var byt = []byte(str)
var arr = strings.Split(str, "\n")
var _str string //nolint
func BenchmarkStringSParallel(b *testing.B) {
b.ReportAllocs()
b.SetParallelism(100)
b.RunParallel(func(pb *testing.PB) {
var ret string
for pb.Next() {
ret = StringS(arr)
_str = ret
}
})
}
func BenchmarkStringBSParallel(b *testing.B) {
b.ReportAllocs()
b.SetParallelism(100)
b.RunParallel(func(pb *testing.PB) {
var ret string
for pb.Next() {
ret = StringBS(arr)
_str = ret
}
})
}
func BenchmarkStringBSPParallel(b *testing.B) {
b.ReportAllocs()
b.SetParallelism(100)
b.RunParallel(func(pb *testing.PB) {
var ret string
for pb.Next() {
ret = StringBSP(arr)
_str = ret
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment