BenchmarkSyscallsCommand is the entrypoint for the benchmark syscalls command.
(cfg *config.Config)
| 360 | |
| 361 | // BenchmarkSyscallsCommand is the entrypoint for the benchmark syscalls command. |
| 362 | func 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 | |
| 391 | func benchmark(iterations int, path string) error { |
| 392 | tests := map[string]func() error{ |
no test coverage detected