4 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto b7563c327b mruby-benchmark: standardize block parameter spacing
changed block spacing from { | to {| for consistency.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:09 +09:00
Yukihiro "Matz" Matsumoto 2336534552 mruby-benchmark: add comprehensive test suite
add 24 test cases covering all benchmark functionality:
- Benchmark.measure and Benchmark.realtime
- Benchmark::Tms class and its methods (total, to_s, format)
- Benchmark.bm for formatted comparison reports
- Benchmark::Report class
- memory tracking with ObjectSpace integration
- consistency and realistic usage scenarios

suppress output during tests by temporarily setting $stdout to nil
for tests that call Benchmark.bm or Report#report to avoid printing
garbage during test execution.

all tests pass successfully.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-02 23:12:37 +09:00
Yukihiro "Matz" Matsumoto 13e2ce4249 mruby-benchmark: fix implementation for mruby environment
fix implementation to work correctly in mruby:
- use String#% instead of sprintf for formatting
- use $stdout directly for output instead of bare print/puts
- add nil check for $stdout to handle test environments
- use Object.const_defined? instead of defined? keyword
- create new Tms instance with label instead of instance_variable_set
- add dependencies: mruby-sprintf and mruby-io

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-02 23:12:36 +09:00
Yukihiro "Matz" Matsumoto 2f40f3d170 mruby-benchmark: add benchmarking gem
add initial implementation of mruby-benchmark gem providing:
- Benchmark.measure for detailed timing with Tms results
- Benchmark.realtime for simple wall-clock measurements
- Benchmark.bm for formatted comparison reports
- optional memory tracking via ObjectSpace integration

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-02 23:12:36 +09:00