Consider using the trivial `id` benchmark on an example output-type value as a baseline or lower measurement sanity bound
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- haskell
- Lĩnh vực
- performance
Hướng nghiên cứu
Bắt đầu bằng cách lần theo cách bench và nf được xử lý, sau đó xem xét entry point defaultMain và cách tiếp cận Template Haskell được đề xuất. Xác định liệu Criterion có thể đo một output-type id baseline ở bên trong hay không và điều đó sẽ ảnh hưởng thế nào đến các phép đo khác; công việc được hoàn tất khi có quyết định cụ thể về tính khả thi và hành vi được xác định cho việc trừ baseline hoặc đưa ra cảnh báo khi các phép đo gần với baseline.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I just started experimenting with a tiny function that does some bit twiddling (compiled to a handful of instructions, ideally). It looks like
innerLoop :: Word8 -> Word32
Then for testing purposes I have hand-unrolled variants that just do the same operation 4 times, 8 times, etc.
innderLoop8 :: :: (Word8 , Word8 , Word8 , Word8) -> Word32 -- and so on
A test run gives output something like:
innerLoop = 9.37
innerLoop4 = 12.66
innerLoop8 = 17.83
So it looks like there's overhead somewhere that's not from the precise code I'm interested in. Obviously at this scale, that's not unexpected. But I was curious if I could measure this overhead directly, so I added an id benchmark on a value of the expected output type of the functions I was testing:
-- `id` might work too, or maybe some rewriting will happen that we don't want:
, bench "baseline" $ nf (\x-> x) (0 :: Word32)
]
Which gave:
benchmarking baseline
time 9.494 ns (9.471 ns .. 9.519 ns)
1.000 R² (1.000 R² .. 1.000 R²)
mean 9.495 ns (9.464 ns .. 9.536 ns)
std dev 121.5 ps (99.28 ps .. 163.7 ps)
variance introduced by outliers: 15% (moderately inflated)
If I subtract this measured "overhead" from my other measurements (posted above) the results seem sensible; they're both in line with what I'd expect from the compiled code (haven't looked at assembly yet) and the time increases linearly-ish.
I then tried out a baseline benchmark with () like bench "baseline" $ nf (\x-> x) () which was a little faster, suggesting this is measuring the overhead of nf, not just, say, the cost of a function call per se or something:
benchmarking baseline()
time 6.781 ns (6.753 ns .. 6.818 ns)
1.000 R² (0.999 R² .. 1.000 R²)
mean 6.810 ns (6.774 ns .. 6.864 ns)
std dev 141.1 ps (103.7 ps .. 202.2 ps)
variance introduced by outliers: 33% (moderately inflated)
So my proposal: I wonder if it makes sense for criterion to do some or all of:
- for each
benchline demand the user provide an example value of the result type (or use a Default type class or something), and run theidbenchmark on that - use the resulting value as a baseline for the other measurements
- complain when the measured value is too close to the baseline to be of any value (e.g. as in my
innerLoop)
I wonder if it's even possible for criterion to do this internally, i.e. if we can only "accurately" measure this overhead in the way shown above. In that case it would be possible to use Template Haskell in a new defaultMain-style splice but which inserts new baseline stanzas (and then obviously processes the output, combining benchmarks with their baseline).
- Ngôn ngữ chính
- Haskell
- Star
- 525
- Fork
- 88
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của haskell/criterion
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
-
first benchmark is expensiveĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 48/100
Tất cả issue của haskell/criterion
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
haskell/bytestring#730 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
seal-harness/seal-harness#399 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
add previously overlooked rulesĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
fmidue/codeworld-tasks#124 ·
-
allow haskell-src-exts-1.24Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
reflex-frp/reflex#563 ·