Class: Mach5::Benchmark

Inherits:
Object
  • Object
show all
Defined in:
lib/mach5-tools/benchmark.rb

Instance Method Summary collapse

Constructor Details

#initialize(memory, tags) ⇒ Benchmark

Returns a new instance of Benchmark.



3
4
5
6
# File 'lib/mach5-tools/benchmark.rb', line 3

def initialize(memory, tags)
  @memory = memory
  @tags = tags
end

Instance Method Details

#[](commit_id) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/mach5-tools/benchmark.rb', line 8

def [](commit_id)
  benchmarks = @memory[commit_id]
  if benchmarks
    benchmarks
  else
    @memory[@tags[commit_id]]
  end
end

#add(commit_id, value) ⇒ Object



17
18
19
20
# File 'lib/mach5-tools/benchmark.rb', line 17

def add(commit_id, value)
  @memory[commit_id] ||= []
  @memory[commit_id] << value
end

#commitsObject



26
27
28
# File 'lib/mach5-tools/benchmark.rb', line 26

def commits
  @memory.keys
end

#has_tag?(commit_id) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/mach5-tools/benchmark.rb', line 34

def has_tag?(commit_id)
  @tags.invert[commit_id]
end

#tag(commit_id, tag_name) ⇒ Object



22
23
24
# File 'lib/mach5-tools/benchmark.rb', line 22

def tag(commit_id, tag_name)
  @tags[tag_name] = commit_id
end

#taggedObject



30
31
32
# File 'lib/mach5-tools/benchmark.rb', line 30

def tagged
  @tags
end