metric_system 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metric_system.rb +5 -1
- data/lib/metric_system/io.rb +5 -1
- data/lib/metric_system/server.rb +1 -1
- data/lib/metric_system/version.rb +1 -1
- data/test/parallel_now.rb +59 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ad1cd2f461e034ff092a61170114e845edd7043
|
4
|
+
data.tar.gz: 030eb76f637f1f22fa881ec7aca9e47ee923ac86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 564412acff6d5cc39ef9bdea325126455536de2598f661e518763e06a5f14b2da9009c4f715247fb719a9131099976a98b135619e353fa8c00e4546ba433fd77
|
7
|
+
data.tar.gz: 8b1cf3a4c654b6b0c19d4ab14b423ff7a75fd88d5dea8e86e645f3673ed67c729626e720a80a70931447dedd31f6dadcaf1ebf1243ed27cad5f1331862ad6d68
|
data/lib/metric_system.rb
CHANGED
data/lib/metric_system/io.rb
CHANGED
@@ -5,7 +5,11 @@ class MetricSystem::IO
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def add_event(table, name, value, starts_at)
|
8
|
-
|
8
|
+
if starts_at
|
9
|
+
starts_at = Time.parse(starts_at) if starts_at.is_a?(String)
|
10
|
+
starts_at = starts_at.to_i
|
11
|
+
end
|
12
|
+
|
9
13
|
@io.puts "#{table} #{name} #{value} #{starts_at}"
|
10
14
|
end
|
11
15
|
|
data/lib/metric_system/server.rb
CHANGED
@@ -30,7 +30,7 @@ module MetricSystem::Server
|
|
30
30
|
def self.parse(line)
|
31
31
|
table, name, value, time, remainder = line.split(" ", 5)
|
32
32
|
value = value.to_f
|
33
|
-
time = time ? time.to_i :
|
33
|
+
time = time != "" ? time.to_i : nil
|
34
34
|
new(table, name, value, time)
|
35
35
|
end
|
36
36
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
$: << "#{File.dirname(__FILE__)}/../lib"
|
2
|
+
require "metric_system"
|
3
|
+
|
4
|
+
SOCKET = "performance.socket"
|
5
|
+
DBPATH = "samples.sqlite"
|
6
|
+
|
7
|
+
mode, _ = *ARGV
|
8
|
+
if mode == nil then
|
9
|
+
require "metric_system/server"
|
10
|
+
|
11
|
+
Thread.new do
|
12
|
+
sleep 1
|
13
|
+
system "ruby #{__FILE__} sender"
|
14
|
+
end
|
15
|
+
|
16
|
+
MetricSystem::Server.run DBPATH, SOCKET, :quit_server => true
|
17
|
+
|
18
|
+
puts "server stopped"
|
19
|
+
|
20
|
+
MetricSystem.print "SELECT * FROM aggregates"
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
|
24
|
+
# ---------------------------------------------------------------------
|
25
|
+
|
26
|
+
def benchmark(msg, &block)
|
27
|
+
starts = Time.now
|
28
|
+
|
29
|
+
yield
|
30
|
+
|
31
|
+
ensure
|
32
|
+
runtime = Time.now - starts
|
33
|
+
if runtime > 0.1
|
34
|
+
STDERR.puts "%s: %.3f secs" % [ msg, runtime = Time.now - starts ]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
TICKS = 10
|
39
|
+
|
40
|
+
File.unlink(DBPATH) rescue nil
|
41
|
+
|
42
|
+
require "time"
|
43
|
+
require "socket"
|
44
|
+
|
45
|
+
benchmark "Sending #{TICKS} events to metric_system" do
|
46
|
+
MetricSystem.target = UNIXSocket.new(SOCKET)
|
47
|
+
1.upto(TICKS) do |day|
|
48
|
+
MetricSystem.count "clicks", 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
STDERR.puts "Quitting server"
|
53
|
+
MetricSystem.quit_server!
|
54
|
+
|
55
|
+
__END__
|
56
|
+
|
57
|
+
db.print "SELECT COUNT(*) FROM aggregates"
|
58
|
+
|
59
|
+
db.print "SELECT * FROM aggregates"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metric_system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- radiospiel
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- test/gauges_test.rb
|
64
64
|
- test/mixed_test.rb
|
65
65
|
- test/parallel.rb
|
66
|
+
- test/parallel_now.rb
|
66
67
|
homepage: http://github.com/radiospiel/metric_system
|
67
68
|
licenses: []
|
68
69
|
metadata: {}
|