MCPcopy
hub / github.com/opencloud-eu/opencloud / BenchmarkSyscallsCommand

Function BenchmarkSyscallsCommand

opencloud/pkg/command/benchmark.go:362–389  ·  view source on GitHub ↗

BenchmarkSyscallsCommand is the entrypoint for the benchmark syscalls command.

(cfg *config.Config)

Source from the content-addressed store, hash-verified

360
361// BenchmarkSyscallsCommand is the entrypoint for the benchmark syscalls command.
362func BenchmarkSyscallsCommand(cfg *config.Config) *cobra.Command {
363 benchSysCallCmd := &cobra.Command{
364 Use: "syscalls",
365 Short: "test the performance of syscalls",
366 RunE: func(cmd *cobra.Command, args []string) error {
367
368 path, _ := cmd.Flags().GetString("path")
369 if path == "" {
370 f, err := os.CreateTemp("", "opencloud-bench-temp-")
371 if err != nil {
372 log.Fatal(err)
373 }
374 path = f.Name()
375 f.Close()
376 defer os.Remove(path)
377 }
378
379 iterations, err := cmd.Flags().GetInt("iterations")
380 if err != nil {
381 return err
382 }
383 return benchmark(iterations, path)
384 },
385 }
386 benchSysCallCmd.Flags().String("path", "", "Path to test")
387 benchSysCallCmd.Flags().Int("iterations", 100, "Number of iterations to execute")
388 return benchSysCallCmd
389}
390
391func benchmark(iterations int, path string) error {
392 tests := map[string]func() error{

Callers 1

BenchmarkCommandFunction · 0.85

Calls 4

benchmarkFunction · 0.70
CloseMethod · 0.65
NameMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected