corn 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/corn.rb +9 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1425655cf5cdd11171b749f547a74dfa9f45f54
4
- data.tar.gz: 913f8c03f6c74bcf3aa2b74bb647b4bb9543c281
3
+ metadata.gz: 2794de12eebae473fe6e080c9540e88e47d3358d
4
+ data.tar.gz: bb75e03506695bc2d02076fe7d77d153c7a0f66c
5
5
  SHA512:
6
- metadata.gz: 992c4bc7ea7f4e9326ea0db58ff12cac29766e741aacfd40312fcb01e4fdaa2eb1034743e50e8a280fb1792c0b3215a9165c8c698f9ce107119270887b766ce5
7
- data.tar.gz: 98804618e0d6013d20f90ca7f84396b38a3b9b997b10a6cb827ca57fdfdd63db0e14b9269d8c04a0383ce0e51bf8190af0dc3c701740f88fd88d9774e8822a84
6
+ metadata.gz: 4b7fcdb777001eb9700dc08176afb9f5de994e713a13914c4528e3b69a7a8ec9190304e3ab3857613fb523ddae51c55a1797b2bf6956de66d125442da3dc28d1
7
+ data.tar.gz: e04a9c049b8ebd6aab24339f926db4d2046648fc48bc9f0d566b03bcc0be04a1fcd1f939facedf0fe25a2fbb6856505c3fda76700a9f263befc3cb6051067bf6
@@ -28,14 +28,16 @@ module Corn
28
28
  def start(output=nil, period=0.1)
29
29
  @prof ||= create_prof(period, output)
30
30
  @prof.start
31
+ @prof_start_at = Time.now
31
32
  end
32
33
 
33
34
  def submit(name)
35
+ runtime, @prof_start_at = (Time.now - @prof_start_at), nil
34
36
  @prof.stop
35
37
  if configured?
36
- upload(@prof.output_file, name)
38
+ upload(@prof.output_file, name, runtime)
37
39
  else
38
- log("No CORN_CLIENT_ID configured, profiling data is not submitted")
40
+ log("No CORN_CLIENT_ID or CORN_HOST configured, profiling data is not submitted")
39
41
  end
40
42
  end
41
43
 
@@ -47,19 +49,21 @@ module Corn
47
49
  $stderr.puts msg
48
50
  end
49
51
 
50
- def upload(file, name)
52
+ def upload(file, name, runtime)
51
53
  url = URI.parse(submit_url)
52
54
  File.open(file) do |f|
53
55
  req = Net::HTTP::Post::Multipart.new(url.path,
54
56
  "data" => UploadIO.new(f, "text/plain"),
55
57
  'client_id' => client_id,
56
- 'name' => name)
58
+ 'name' => name,
59
+ 'runtime' => runtime)
57
60
  res = Net::HTTP.start(url.host, url.port) do |http|
58
61
  http.use_ssl = url.scheme == 'https'
59
62
  http.request(req)
60
63
  end
61
64
  end
62
- rescue => e
65
+ log("Corn report submitted to #{submit_url}")
66
+ rescue Exception => e
63
67
  log("upload #{file} to #{submit_url} failed: #{e.message}")
64
68
  log(e.backtrace.join("\n"))
65
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xiao Li
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-03-10 00:00:00 Z
12
+ date: 2014-03-14 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multipart-post