Logs Automatically purges themselves

This commit is contained in:
Luis Fernando Molina committed 2018-03-17 17:04:07 +01:00
1 parent fda24f934c
commit a42174b233
632 files changed
+19952 -20039

No files matched your search

+4 -2
View File
@@ -1,4 +1,6 @@
language: node_js
node_js:
- "0.10"
- "0.8"
- "node"
- "6"
- "4"
- "0.12"
-25
View File
@@ -1,25 +0,0 @@
build:
mkdir -p lib
rm -rf lib/*
node_modules/.bin/coffee --compile --output lib/ src/
watch:
node_modules/.bin/coffee --watch --compile --output lib/ src/
test:
node_modules/.bin/mocha
jumpstart:
curl -u 'meryn' https://api.github.com/user/repos -d '{"name":"performance-now", "description":"Implements performance.now (based on process.hrtime).","private":false}'
mkdir -p src
touch src/performance-now.coffee
mkdir -p test
touch test/performance-now.coffee
npm install
git init
git remote add origin git@github.com:meryn/performance-now
git add .
git commit -m "jumpstart commit."
git push -u origin master
.PHONY: test
+11 -11
View File
@@ -1,30 +1,30 @@
# performance-now [![Build Status](https://travis-ci.org/meryn/performance-now.png?branch=master)](https://travis-ci.org/meryn/performance-now) [![Dependency Status](https://david-dm.org/meryn/performance-now.png)](https://david-dm.org/meryn/performance-now)
# performance-now [![Build Status](https://travis-ci.org/braveg1rl/performance-now.png?branch=master)](https://travis-ci.org/braveg1rl/performance-now) [![Dependency Status](https://david-dm.org/braveg1rl/performance-now.png)](https://david-dm.org/braveg1rl/performance-now)
Implements a function similar to `performance.now` (based on `process.hrtime`).
Modern browsers have a `window.performance` object with - among others - a `now` method which gives time in miliseconds, but with sub-milisecond precision. This module offers the same function based on the Node.js native `process.hrtime` function.
According to the [High Resolution Time specification](http://www.w3.org/TR/hr-time/), the number of miliseconds reported by `performance.now` should be relative to the value of `performance.timing.navigationStart`. For this module, it's relative to when the time when this module got loaded. Right after requiring this module for the first time, the reported time is expected to have a near-zero value.
Modern browsers have a `window.performance` object with - among others - a `now` method which gives time in milliseconds, but with sub-millisecond precision. This module offers the same function based on the Node.js native `process.hrtime` function.
Using `process.hrtime` means that the reported time will be monotonically increasing, and not subject to clock-drift.
According to the [High Resolution Time specification](http://www.w3.org/TR/hr-time/), the number of milliseconds reported by `performance.now` should be relative to the value of `performance.timing.navigationStart`.
In the current version of the module (2.0) the reported time is relative to the time the current Node process has started (inferred from `process.uptime()`).
Version 1.0 reported a different time. The reported time was relative to the time the module was loaded (i.e. the time it was first `require`d). If you need this functionality, version 1.0 is still available on NPM.
## Example usage
```javascript
var now = require("performance-now")
var start = now()
var end = now()
console.log(start.toFixed(3)) // ~ 0.05 on my system
console.log(start.toFixed(3)) // the number of milliseconds the current node process is running
console.log((start-end).toFixed(3)) // ~ 0.002 on my system
```
Running the now function two times right after each other yields a time difference of a few microseconds. Given this overhead, I think it's best to assume that the precision of intervals computed with this method is not higher than 10 microseconds, if you don't know the exact overhead on your own system.
## Credits
The initial structure of this module was generated by [Jumpstart](https://github.com/meryn/jumpstart), using the [Jumpstart Black Coffee](https://github.com/meryn/jumpstart-black-coffee) template.
## License
performance-now is released under the [MIT License](http://opensource.org/licenses/MIT).
Copyright (c) 2013 Meryn Stol
performance-now is released under the [MIT License](http://opensource.org/licenses/MIT).
Copyright (c) 2017 Braveg1rl
+8 -4
View File
@@ -1,6 +1,6 @@
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.12.2
(function() {
var getNanoSeconds, hrtime, loadTime;
var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime;
if ((typeof performance !== "undefined" && performance !== null) && performance.now) {
module.exports = function() {
@@ -8,7 +8,7 @@
};
} else if ((typeof process !== "undefined" && process !== null) && process.hrtime) {
module.exports = function() {
return (getNanoSeconds() - loadTime) / 1e6;
return (getNanoSeconds() - nodeLoadTime) / 1e6;
};
hrtime = process.hrtime;
getNanoSeconds = function() {
@@ -16,7 +16,9 @@
hr = hrtime();
return hr[0] * 1e9 + hr[1];
};
loadTime = getNanoSeconds();
moduleLoadTime = getNanoSeconds();
upTime = process.uptime() * 1e9;
nodeLoadTime = moduleLoadTime - upTime;
} else if (Date.now) {
module.exports = function() {
return Date.now() - loadTime;
@@ -30,3 +32,5 @@
}
}).call(this);
//# sourceMappingURL=performance-now.js.map
+10
View File
@@ -0,0 +1,10 @@
{
"version": 3,
"file": "performance-now.js",
"sourceRoot": "..",
"sources": [
"src/performance-now.coffee"
],
"names": [],
"mappings": ";AAAA;AAAA,MAAA;;EAAA,IAAG,4DAAA,IAAiB,WAAW,CAAC,GAAhC;IACE,MAAM,CAAC,OAAP,GAAiB,SAAA;aAAG,WAAW,CAAC,GAAZ,CAAA;IAAH,EADnB;GAAA,MAEK,IAAG,oDAAA,IAAa,OAAO,CAAC,MAAxB;IACH,MAAM,CAAC,OAAP,GAAiB,SAAA;aAAG,CAAC,cAAA,CAAA,CAAA,GAAmB,YAApB,CAAA,GAAoC;IAAvC;IACjB,MAAA,GAAS,OAAO,CAAC;IACjB,cAAA,GAAiB,SAAA;AACf,UAAA;MAAA,EAAA,GAAK,MAAA,CAAA;aACL,EAAG,CAAA,CAAA,CAAH,GAAQ,GAAR,GAAc,EAAG,CAAA,CAAA;IAFF;IAGjB,cAAA,GAAiB,cAAA,CAAA;IACjB,MAAA,GAAS,OAAO,CAAC,MAAR,CAAA,CAAA,GAAmB;IAC5B,YAAA,GAAe,cAAA,GAAiB,OAR7B;GAAA,MASA,IAAG,IAAI,CAAC,GAAR;IACH,MAAM,CAAC,OAAP,GAAiB,SAAA;aAAG,IAAI,CAAC,GAAL,CAAA,CAAA,GAAa;IAAhB;IACjB,QAAA,GAAW,IAAI,CAAC,GAAL,CAAA,EAFR;GAAA,MAAA;IAIH,MAAM,CAAC,OAAP,GAAiB,SAAA;aAAO,IAAA,IAAA,CAAA,CAAM,CAAC,OAAP,CAAA,CAAJ,GAAuB;IAA1B;IACjB,QAAA,GAAe,IAAA,IAAA,CAAA,CAAM,CAAC,OAAP,CAAA,EALZ;;AAXL"
}
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2013 Meryn Stol
Copyright (c) 2013 Braveg1rl
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+35 -43
View File
@@ -1,76 +1,68 @@
{
"_args": [
[
"performance-now@^0.2.0",
"c:\\users\\luis\\source\\repos\\AACharly\\node_modules\\azure-storage\\node_modules\\request"
"performance-now@2.1.0",
"C:\\Users\\Luis\\source\\repos\\AACloud"
]
],
"_from": "performance-now@>=0.2.0-0 <0.3.0-0",
"_id": "performance-now@0.2.0",
"_inCache": true,
"_from": "performance-now@2.1.0",
"_id": "performance-now@2.1.0",
"_inBundle": false,
"_integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=",
"_location": "/performance-now",
"_npmUser": {
"email": "merynstol@gmail.com",
"name": "meryn"
},
"_npmVersion": "1.3.24",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "performance-now@2.1.0",
"name": "performance-now",
"raw": "performance-now@^0.2.0",
"rawSpec": "^0.2.0",
"scope": null,
"spec": ">=0.2.0-0 <0.3.0-0",
"type": "range"
"escapedName": "performance-now",
"rawSpec": "2.1.0",
"saveSpec": null,
"fetchSpec": "2.1.0"
},
"_requiredBy": [
"/azure-storage/request"
"/request"
],
"_resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz",
"_shasum": "33ef30c5c77d4ea21c5a53869d91b56d8f2555e5",
"_shrinkwrap": null,
"_spec": "performance-now@^0.2.0",
"_where": "c:\\users\\luis\\source\\repos\\AACharly\\node_modules\\azure-storage\\node_modules\\request",
"_resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"_spec": "2.1.0",
"_where": "C:\\Users\\Luis\\source\\repos\\AACloud",
"author": {
"email": "merynstol@gmail.com",
"name": "Meryn Stol"
"name": "Braveg1rl",
"email": "braveg1rl@outlook.com"
},
"bugs": {
"url": "https://github.com/meryn/performance-now/issues"
"url": "https://github.com/braveg1rl/performance-now/issues"
},
"dependencies": {},
"description": "Implements performance.now (based on process.hrtime).",
"devDependencies": {
"coffee-script": "~1.7.1",
"mocha": "~1.21.0"
"bluebird": "^3.4.7",
"call-delayed": "^1.0.0",
"chai": "^3.5.0",
"chai-increasing": "^1.2.0",
"coffee-script": "~1.12.2",
"mocha": "~3.2.0",
"pre-commit": "^1.2.2"
},
"directories": {},
"dist": {
"shasum": "33ef30c5c77d4ea21c5a53869d91b56d8f2555e5",
"tarball": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz"
},
"homepage": "https://github.com/meryn/performance-now",
"installable": true,
"homepage": "https://github.com/braveg1rl/performance-now",
"keywords": [],
"license": "MIT",
"main": "lib/performance-now.js",
"maintainers": [
{
"name": "meryn",
"email": "merynstol@gmail.com"
}
],
"name": "performance-now",
"optionalDependencies": {},
"private": false,
"repository": {
"type": "git",
"url": "git://github.com/meryn/performance-now.git"
"url": "git://github.com/braveg1rl/performance-now.git"
},
"scripts": {
"build": "mkdir -p lib && rm -rf lib/* && node_modules/.bin/coffee --compile -m --output lib/ src/",
"prepublish": "npm test",
"pretest": "make build",
"test": "make test"
"pretest": "npm run build",
"test": "mocha",
"watch": "coffee --watch --compile --output lib/ src/"
},
"version": "0.2.0"
"typings": "src/index.d.ts",
"version": "2.1.0"
}
+8
View File
@@ -0,0 +1,8 @@
// This file describes the package to typescript.
/**
* Returns the number of milliseconds since the page was loaded (if browser)
* or the node process was started.
*/
declare function now(): number;
export = now;
+4 -2
View File
@@ -1,12 +1,14 @@
if performance? and performance.now
module.exports = -> performance.now()
else if process? and process.hrtime
module.exports = -> (getNanoSeconds() - loadTime) / 1e6
module.exports = -> (getNanoSeconds() - nodeLoadTime) / 1e6
hrtime = process.hrtime
getNanoSeconds = ->
hr = hrtime()
hr[0] * 1e9 + hr[1]
loadTime = getNanoSeconds()
moduleLoadTime = getNanoSeconds()
upTime = process.uptime() * 1e9
nodeLoadTime = moduleLoadTime - upTime
else if Date.now
module.exports = -> Date.now() - loadTime
loadTime = Date.now()
+38 -33
View File
@@ -1,38 +1,43 @@
assert = require "assert"
chai = require "chai"
chai.use(require "chai-increasing")
{assert,expect} = chai
Bluebird = require "bluebird"
now = require "../"
getUptime = -> process.uptime() * 1e3
delay = (ms, fn) -> setTimeout fn, ms
now = undefined
describe "now", ->
it "initially gives a near zero (< 20 ms) time ", ->
now = require "../"
assert now() < 20
it "gives a positive time", ->
assert now() > 0
it "reported time differs at most 1ms from a freshly reported uptime", ->
assert.isAtMost Math.abs(now()-getUptime()), 1
it "two subsequent calls return an increasing number", ->
a = now()
b = now()
assert now() < now()
it "has less than 10 microseconds overhead", ->
Math.abs(now() - now()) < 0.010
it "can do 1,000,000 calls really quickly", ->
now() for i in [0...1000000]
it "shows that at least 990 ms has passed after a timeout of 1 second", (done) ->
a = now()
delay 1000, ->
b = now()
diff = b - a
return done new Error "Diff (#{diff}) lower than 990." if diff < 990
return done null
assert.isBelow now(), now()
it "shows that not more than 1020 ms has passed after a timeout of 1 second", (done) ->
a = now()
delay 1000, ->
b = now()
diff = b - a
return done new Error "Diff (#{diff}) higher than 1020." if diff > 1020
return done null
it "has less than 10 microseconds overhead", ->
assert.isBelow Math.abs(now() - now()), 0.010
it "can be called 1 million times in under 1 second (averaging under 1 microsecond per call)", ->
@timeout 1000
now() for [0...1e6]
undefined
it "for 10,000 numbers, number n is never bigger than number n-1", ->
stamps = (now() for [1...10000])
expect(stamps).to.be.increasing
it "shows that at least 0.2 ms has passed after a timeout of 1 ms", ->
earlier = now()
Bluebird.resolve().delay(1).then -> assert.isAbove (now()-earlier), 0.2
it "shows that at most 3 ms has passed after a timeout of 1 ms", ->
earlier = now()
Bluebird.resolve().delay(1).then -> assert.isBelow (now()-earlier), 3
it "shows that at least 190ms ms has passed after a timeout of 200ms", ->
earlier = now()
Bluebird.resolve().delay(200).then -> assert.isAbove (now()-earlier), 190
it "shows that at most 220 ms has passed after a timeout of 200ms", ->
earlier = now()
Bluebird.resolve().delay(200).then -> assert.isBelow (now()-earlier), 220
+27
View File
@@ -0,0 +1,27 @@
Bluebird = require "bluebird"
exec = require("child_process").execSync
{assert} = require "chai"
describe "scripts/initital-value.coffee (module.uptime(), expressed in milliseconds)", ->
result = exec("./test/scripts/initial-value.coffee").toString().trim()
it "printed #{result}", ->
it "printed a value above 100", -> assert.isAbove result, 100
it "printed a value below 350", -> assert.isBelow result, 350
describe "scripts/delayed-require.coffee (sum of uptime and 250 ms delay`)", ->
result = exec("./test/scripts/delayed-require.coffee").toString().trim()
it "printed #{result}", ->
it "printed a value above 350", -> assert.isAbove result, 350
it "printed a value below 600", -> assert.isBelow result, 600
describe "scripts/delayed-call.coffee (sum of uptime and 250 ms delay`)", ->
result = exec("./test/scripts/delayed-call.coffee").toString().trim()
it "printed #{result}", ->
it "printed a value above 350", -> assert.isAbove result, 350
it "printed a value below 600", -> assert.isBelow result, 600
describe "scripts/difference.coffee", ->
result = exec("./test/scripts/difference.coffee").toString().trim()
it "printed #{result}", ->
it "printed a value above 0.005", -> assert.isAbove result, 0.005
it "printed a value below 0.07", -> assert.isBelow result, 0.07
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env ./node_modules/.bin/coffee
###
Expected output is a number above 350 and below 600.
The time reported is relative to the time the node.js process was started
this is approximately at `(Date.now() process.uptime() * 1000)`
###
delay = require "call-delayed"
now = require "../../lib/performance-now"
delay 250, -> console.log now().toFixed 3
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env ./node_modules/.bin/coffee
###
Expected output is a number above 350 and below 600.
The time reported is relative to the time the node.js process was started
this is approximately at `(Date.now() process.uptime() * 1000)`
###
delay = require "call-delayed"
delay 250, ->
now = require "../../lib/performance-now"
console.log now().toFixed 3
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env ./node_modules/.bin/coffee
# Expected output is above 0.005 and below 0.07.
now = require('../../lib/performance-now')
console.log -(now() - now()).toFixed 3
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env ./node_modules/.bin/coffee
###
Expected output is a number above 100 and below 350.
The time reported is relative to the time the node.js process was started
this is approximately at `(Date.now() process.uptime() * 1000)`
###
now = require '../../lib/performance-now'
console.log now().toFixed 3