picky-statistics 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,19 +37,16 @@ module Statistics
37
37
  end
38
38
  def initialize_full_totals
39
39
  full[:totals] = {}
40
- full[:totals][0] = Count.new "^>|.*| 0|"
41
- full[:totals][1] = Count.new "^>|.*| 1|"
42
- full[:totals][2] = Count.new "^>|.*| 2|"
43
- full[:totals][3] = Count.new "^>|.*| 3|"
44
-
45
- full[:totals][:'4+'] = Count.new("^>|.*| [4-9]|", # 4-9, with one or more allocs
46
- "^>|.*| [1-9].|") # but less than 100
47
-
48
- full[:totals][:cloud] = Count.new("^>|.*|[1-9].|", # allocs 10+
49
- "^>|.*|.*|......[1-9].|....|.[2-9]|") # allocs 2-9, more than 10 results
50
-
51
- full[:totals][:'100+'] = Count.new "^>|.*|.*| [1-9]..|"
40
+ full[:totals][0] = Count.new "^>|.*| 0|"
41
+ full[:totals][1] = Count.new "^>|.*| 1|"
42
+ full[:totals][2] = Count.new "^>|.*| 2|"
43
+ full[:totals][3] = Count.new "^>|.*| 3|"
44
+ full[:totals][:'4+'] = Count.new("^>|.*| [4-9]|", "^>|.*| [1-9][0-9]|") # 4-9, 10+, but less than 100
45
+ full[:totals][:'100+'] = Count.new "^>|.*|.*| [1-9][0-9][0-9]|"
52
46
  full[:totals][:'1000+'] = Count.new "^>|.*|.*|....[0-9]...|"
47
+
48
+ full[:totals][:cloud] = Count.new("^>|.*|[1-9].|", # allocs 10+
49
+ "^>|.*|.*|......[1-9].|....|.[2-9]|") # allocs 2-9, more than 10 results
53
50
  end
54
51
  def initialize_live_totals
55
52
 
@@ -60,14 +57,17 @@ module Statistics
60
57
  full[:very_long_running] = Count.new "^>|.\\+\\?|[1-9]\\.......|"
61
58
 
62
59
  full[:offset] = Count.new("^>|.*|[ 1-9][ 0-9][0-9][0-9]|", # offset 10+
63
- "^>|.*| [1-9]") # offset 1-9
60
+ "^>|.*| [1-9]") # offset 1-9
64
61
  end
65
62
 
66
63
  #
67
64
  #
68
65
  def since_last
69
66
  @last_offset ||= 0
70
- puts "Parsing log files from last parse point at line #{@last_offset}."
67
+
68
+ log_offset = @last_offset
69
+ start_time = Time.now
70
+
71
71
  with_temp_file(@last_offset) do |statistics|
72
72
  calculate_last_offset_from statistics
73
73
 
@@ -92,7 +92,8 @@ module Statistics
92
92
  full[:offset].add_from statistics
93
93
  end
94
94
 
95
- puts "Statistics generated."
95
+ duration = Time.now - start_time
96
+ puts "Parsed log from line #{log_offset} in #{duration}s"
96
97
 
97
98
  @counts
98
99
  end
@@ -113,14 +114,13 @@ module Statistics
113
114
  # Use the offset to speed up statistics gathering.
114
115
  #
115
116
  def with_temp_file offset = 0
116
- # Tempfile.open 'picky' do |temp_file| # TODO Use temp file.
117
- File.open('picky_statistics.tmp', 'w+') do |temp_file|
118
- temp_path = temp_file.path
119
- puts "Copying #{@path} to #{temp_path} beginning at line #{offset}."
120
- `tail -n +#{offset} #{@path} > #{temp_path}`
121
- yield temp_path
122
- File.delete temp_path
123
- end
117
+ temp_file = Tempfile.new 'picky'
118
+
119
+ temp_path = temp_file.path
120
+ `tail -n +#{offset} #{@path} > #{temp_path}`
121
+ yield temp_path
122
+
123
+ temp_file.delete
124
124
  end
125
125
 
126
126
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 2
8
- - 1
9
- version: 1.2.1
8
+ - 2
9
+ version: 1.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Florian Hanke
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-20 00:00:00 +01:00
17
+ date: 2010-12-21 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency