Files
wazero/internal/platform/bench_test.go
Edoardo Vacchi d63813a830 fs: stat and cache mode for stdio devices (#1295)
Ensure that stdio device modes are consistent with the given
file descriptors by stat'ing, instead of returning mocks.

* Use `Stat()` on `poll_oneoff()` too, instead of `IsTerminal()`,
thus avoiding a useless syscall.

* Delete leftover type decl `fileModeStat`.

* Remove IsPlatform()

* Propagate error when Stat() fails

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-03-28 12:48:24 +02:00

30 lines
442 B
Go

package platform
import (
"os"
"path"
"syscall"
"testing"
)
func Benchmark_UtimensFile(b *testing.B) {
tmpDir := b.TempDir()
f, err := os.Create(path.Join(tmpDir, "file"))
if err != nil {
b.Fatal(err)
}
defer f.Close()
times := &[2]syscall.Timespec{
{Sec: 123, Nsec: 4 * 1e3},
{Sec: 123, Nsec: 4 * 1e3},
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
if err := UtimensFile(f, times); err != 0 {
b.Fatal(err)
}
}
}