Class: PerformanceStats
- Inherits:
-
Struct
- Object
- Struct
- PerformanceStats
- Defined in:
- lib/engine/app/lib/commands/performance_stats.rb
Constant Summary collapse
- GET_ACCESS_TIMES =
10_000
- SET_ACCESS_TIMES =
10_000
- CREATE_AND_DELETE_ACCESS_TIMES =
10_000
Instance Attribute Summary collapse
-
#backend ⇒ Object
Returns the value of attribute backend.
Instance Method Summary collapse
- #average_access ⇒ Object
- #average_create_and_delete ⇒ Object
- #average_write ⇒ Object
- #result ⇒ Object
Instance Attribute Details
#backend ⇒ Object
Returns the value of attribute backend
3 4 5 |
# File 'lib/engine/app/lib/commands/performance_stats.rb', line 3 def backend @backend end |
Instance Method Details
#average_access ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/engine/app/lib/commands/performance_stats.rb', line 9 def average_access key = generate_key backend.set(key, rand) time = Benchmark.measure{ GET_ACCESS_TIMES.times{ backend.get(key) } } backend.del(key) time.real / GET_ACCESS_TIMES end |
#average_create_and_delete ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/engine/app/lib/commands/performance_stats.rb', line 27 def average_create_and_delete key = generate_key time = Benchmark.measure do CREATE_AND_DELETE_ACCESS_TIMES.times do backend.set(key, rand) backend.del(key) end end time.real / CREATE_AND_DELETE_ACCESS_TIMES end |
#average_write ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/engine/app/lib/commands/performance_stats.rb', line 19 def average_write key = generate_key time = Benchmark.measure{ SET_ACCESS_TIMES.times{ backend.set(key, rand) } } backend.del(key) time.real / SET_ACCESS_TIMES end |
#result ⇒ Object
39 40 41 42 43 |
# File 'lib/engine/app/lib/commands/performance_stats.rb', line 39 def result { average_access: format_result_in_ms(average_access), average_write: format_result_in_ms(average_write), average_create_and_delete: format_result_in_ms(average_create_and_delete)} end |