Send benchmark data to graphite

This commit is contained in:
Corey Johnson 2012-03-15 17:46:13 -07:00
parent fd5439f357
commit f1003d1e3e
2 changed files with 19 additions and 12 deletions

View File

@ -34,10 +34,16 @@ window.benchmark = (description, fn, profile=false, focused=false) ->
_.times count, fn
console.profileEnd(description) if profile
avg = total / count
report = "#{description}: #{total} / #{count} = #{avg}ms"
fullname = @getFullName().replace(/\s|\.$/g, "")
report = "#{fullname}: #{total} / #{count} = #{avg}ms"
console.log report
throw new Error(report)
if atom.headless
url = "https://github.com/_stats"
data = [type: 'timing', metric: "atom.#{fullname}", ms: avg]
$.post(url, JSON.stringify(data)).
error (e) -> console.log("Failed to store benchmark '#{description}'")
window.measure = (fn) ->
start = new Date().getTime()

View File

@ -2,7 +2,7 @@ Buffer = require 'buffer'
fs = require 'fs'
require 'benchmark-helper'
describe "Editor", ->
describe "editor.", ->
editor = null
beforeEach ->
@ -13,28 +13,29 @@ describe "Editor", ->
afterEach ->
window.shutdown()
benchmark "inserting and deleting a character in an empty file", ->
editor.insertText('x')
editor.backspace()
describe "empty-file.", ->
benchmark "insert-delete", ->
editor.insertText('x')
editor.backspace()
describe "when editing a ~300 line CoffeeScript file", ->
describe "300-line-file.", ->
beforeEach ->
editor.setBuffer new Buffer(require.resolve('fixtures/medium.coffee'))
describe "when the cursor is at the beginning of the file", ->
benchmark "inserting and deleting a character at the beginning of the file", ->
describe "at-begining.", ->
benchmark "insert-delete", ->
editor.insertText('x')
editor.backspace()
benchmark "inserting and deleting a character that causes massive re-highlighting", ->
benchmark "insert-delete-rehighlight", ->
editor.insertText('"')
editor.backspace()
describe "when the cursor is at the end of the file", ->
describe "at-end.", ->
beforeEach ->
editor.setCursorScreenPosition([Infinity, Infinity])
benchmark "inserting and deleting a character", ->
benchmark "insert-delete", ->
editor.insertText('"')
editor.backspace()