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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c313b1e1c7d585f73c1210c3fb3bc610268d804
4
- data.tar.gz: 26cf80941ed294412d5afb60e79b883ae13e2fa8
3
+ metadata.gz: 6ad1cd2f461e034ff092a61170114e845edd7043
4
+ data.tar.gz: 030eb76f637f1f22fa881ec7aca9e47ee923ac86
5
5
  SHA512:
6
- metadata.gz: 1c2b87a70402f5f6090c33f39228c0762777abedbd9f0d27caee1092442a6943a782576a45a48e84b6aec0ce54b4db7080abb9dbbf1a0759575274f0262f847c
7
- data.tar.gz: a8e41c77e9810bed3d53e7bbd6c3e30c167d1ffac75c09d41d7955e6b737534cf2f1d0e618d667e5fd979d0398002caf80fc9730c3a94fa6249cb504aa3ec317
6
+ metadata.gz: 564412acff6d5cc39ef9bdea325126455536de2598f661e518763e06a5f14b2da9009c4f715247fb719a9131099976a98b135619e353fa8c00e4546ba433fd77
7
+ data.tar.gz: 8b1cf3a4c654b6b0c19d4ab14b423ff7a75fd88d5dea8e86e645f3673ed67c729626e720a80a70931447dedd31f6dadcaf1ebf1243ed27cad5f1331862ad6d68
@@ -1,7 +1,11 @@
1
1
  require "expectation"
2
+ require "forwardable"
3
+
4
+ module MetricSystem
5
+ end
2
6
 
3
7
  require_relative "metric_system/core_extensions"
4
- require "forwardable"
8
+ require_relative "metric_system/version"
5
9
 
6
10
  module MetricSystem
7
11
  extend self
@@ -5,7 +5,11 @@ class MetricSystem::IO
5
5
  end
6
6
 
7
7
  def add_event(table, name, value, starts_at)
8
- starts_at = Time.now unless starts_at
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
 
@@ -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 : Time.now.to_i
33
+ time = time != "" ? time.to_i : nil
34
34
  new(table, name, value, time)
35
35
  end
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module MetricSystem
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  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.3
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: {}