rw_test.go 412 B

12345678910111213141516171819202122232425
  1. package stdio
  2. import (
  3. "os"
  4. "testing"
  5. "github.com/langgenius/dify-plugin-daemon/tests"
  6. )
  7. func BenchmarkStdioBandWidth(b *testing.B) {
  8. // open /dev/zero for reading
  9. buf := make([]byte, 1024)
  10. zero := os.NewFile(0, "/dev/zero")
  11. bytes := 0
  12. b.Run("Read", func(b *testing.B) {
  13. for i := 0; i < b.N; i++ {
  14. zero.Read(buf)
  15. bytes += len(buf)
  16. }
  17. })
  18. b.Log("Bytes read:", tests.ReadableBytes(bytes))
  19. }