Heray-Was-Here
Server : LiteSpeed
System : Linux uk-fast-web1372.main-hosting.eu 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User : u390967363 ( 390967363)
PHP Version : 8.2.30
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Directory :  /opt/go/pkg/mod/github.com/go-openapi/swag@v0.22.9/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/go/pkg/mod/github.com/go-openapi/swag@v0.22.9/util_benchmark_test.go
package swag

import (
	"fmt"
	"io"
	"testing"
)

func BenchmarkToXXXName(b *testing.B) {
	samples := []string{
		"sample text",
		"sample-text",
		"sample_text",
		"sampleText",
		"sample 2 Text",
		"findThingById",
		"日本語sample 2 Text",
		"日本語findThingById",
		"findTHINGSbyID",
	}

	b.Run("ToGoName", benchmarkFunc(ToGoName, samples))
	b.Run("ToVarName", benchmarkFunc(ToVarName, samples))
	b.Run("ToFileName", benchmarkFunc(ToFileName, samples))
	b.Run("ToCommandName", benchmarkFunc(ToCommandName, samples))
	b.Run("ToHumanNameLower", benchmarkFunc(ToHumanNameLower, samples))
	b.Run("ToHumanNameTitle", benchmarkFunc(ToHumanNameTitle, samples))
}

func benchmarkFunc(fn func(string) string, samples []string) func(*testing.B) {
	return func(b *testing.B) {
		b.ResetTimer()
		b.ReportAllocs()

		var res string
		for i := 0; i < b.N; i++ {
			res = fn(samples[i%len(samples)])
		}

		fmt.Fprintln(io.Discard, res)
	}
}

Hry