aboutsummaryrefslogtreecommitdiff
path: root/node_modules/nanotiming
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/nanotiming
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/nanotiming')
-rw-r--r--node_modules/nanotiming/.travis.yml8
-rw-r--r--node_modules/nanotiming/LICENSE21
-rw-r--r--node_modules/nanotiming/README.md85
-rw-r--r--node_modules/nanotiming/browser.js48
-rw-r--r--node_modules/nanotiming/example.js21
-rw-r--r--node_modules/nanotiming/index.js45
-rw-r--r--node_modules/nanotiming/package.json34
7 files changed, 262 insertions, 0 deletions
diff --git a/node_modules/nanotiming/.travis.yml b/node_modules/nanotiming/.travis.yml
new file mode 100644
index 00000000..d21e99de
--- /dev/null
+++ b/node_modules/nanotiming/.travis.yml
@@ -0,0 +1,8 @@
+node_js:
+- "7"
+- "8"
+- "9"
+sudo: false
+language: node_js
+script: "npm run test"
+# after_success: "npm i -g codecov && npm run coverage && codecov"
diff --git a/node_modules/nanotiming/LICENSE b/node_modules/nanotiming/LICENSE
new file mode 100644
index 00000000..c03ab533
--- /dev/null
+++ b/node_modules/nanotiming/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Yoshua Wuyts
+
+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:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/node_modules/nanotiming/README.md b/node_modules/nanotiming/README.md
new file mode 100644
index 00000000..e02fd423
--- /dev/null
+++ b/node_modules/nanotiming/README.md
@@ -0,0 +1,85 @@
+# nanotiming [![stability][0]][1]
+[![npm version][2]][3] [![build status][4]][5]
+[![downloads][8]][9] [![js-standard-style][10]][11]
+
+Small timing library. Useful to integrate into libraries that have multiple
+methods. Works both in the browser and Node. To use this in Node, make sure you
+are using v8.5.0 or greater.
+
+## Usage
+```js
+var nanotiming = require('nanotiming')
+// require 'perf_hooks' for Node environment
+// var performance = require('perf_hooks').performance
+
+var timing = nanotiming('my-loop') // Start profiling
+
+var i = 1000
+while (--i) console.log(i)
+
+// Stop profiling
+timing()
+
+// in the browser
+var timings = window.performance.getEntries()
+var timing = timings[timings.length - 1]
+console.log(timing.name, timing.duration) // log the last entry
+window.performance.clearMeasures(timing.name) // be a good citizen and free after use
+
+// in Node
+var timings = performance.getEntries()
+var timing = timings[timings.length - 1]
+console.log(timing.name, timing.duration) // log the last entry
+performance.clearMeasures(timing.name) // be a good citizen and free after use
+```
+
+## Timing names
+Timings inside the view are appended with a unique UUID so they can be cleared
+individually. While there's no strict format for timing formats, we recommend
+using a format along these lines:
+```txt
+choo.render [12356778]
+choo.route('/') [13355671]
+choo.emit('log:debug') [13355675]
+```
+
+## Disabling timings
+Performance timers are still a somewhat experimental technology. While they're
+a great idea conceptually, there might be bugs. To disable timings complete, in
+the browser set:
+```js
+window.localStorage.DISABLE_NANOTIMING = true
+```
+Alternatively, in Node set:
+```js
+process.env.DISABLE_NANOTIMING = true
+```
+
+## API
+### `endTiming = nanotiming(name)`
+Start a new timing.
+
+### `endTiming.uuid`
+The unique ID created for the timing.
+
+### `endTiming([cb(err, name)])`
+Close the timing. Measuring the timing is done inside a `requestIdleCallback()`
+(browser) or `setTimeout` (node) tick, so it might not be available
+immediately. If a callback is passed it will be called with an error (if
+measuring wasn't successful) and the timing's name.
+
+## License
+[MIT](https://tldrlegal.com/license/mit-license)
+
+[0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square
+[1]: https://nodejs.org/api/documentation.html#documentation_stability_index
+[2]: https://img.shields.io/npm/v/nanotiming.svg?style=flat-square
+[3]: https://npmjs.org/package/nanotiming
+[4]: https://img.shields.io/travis/choojs/nanotiming/master.svg?style=flat-square
+[5]: https://travis-ci.org/choojs/nanotiming
+[6]: https://img.shields.io/codecov/c/github/choojs/nanotiming/master.svg?style=flat-square
+[7]: https://codecov.io/github/choojs/nanotiming
+[8]: http://img.shields.io/npm/dm/nanotiming.svg?style=flat-square
+[9]: https://npmjs.org/package/nanotiming
+[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
+[11]: https://github.com/feross/standard
diff --git a/node_modules/nanotiming/browser.js b/node_modules/nanotiming/browser.js
new file mode 100644
index 00000000..c630995d
--- /dev/null
+++ b/node_modules/nanotiming/browser.js
@@ -0,0 +1,48 @@
+var scheduler = require('nanoscheduler')()
+var assert = require('assert')
+
+var perf
+nanotiming.disabled = true
+try {
+ perf = window.performance
+ nanotiming.disabled = window.localStorage.DISABLE_NANOTIMING === 'true' || !perf.mark
+} catch (e) { }
+
+module.exports = nanotiming
+
+function nanotiming (name) {
+ assert.equal(typeof name, 'string', 'nanotiming: name should be type string')
+
+ if (nanotiming.disabled) return noop
+
+ var uuid = (perf.now() * 10000).toFixed() % Number.MAX_SAFE_INTEGER
+ var startName = 'start-' + uuid + '-' + name
+ perf.mark(startName)
+
+ function end (cb) {
+ var endName = 'end-' + uuid + '-' + name
+ perf.mark(endName)
+
+ scheduler.push(function () {
+ var err = null
+ try {
+ var measureName = name + ' [' + uuid + ']'
+ perf.measure(measureName, startName, endName)
+ perf.clearMarks(startName)
+ perf.clearMarks(endName)
+ } catch (e) { err = e }
+ if (cb) cb(err, name)
+ })
+ }
+
+ end.uuid = uuid
+ return end
+}
+
+function noop (cb) {
+ if (cb) {
+ scheduler.push(function () {
+ cb(new Error('nanotiming: performance API unavailable'))
+ })
+ }
+}
diff --git a/node_modules/nanotiming/example.js b/node_modules/nanotiming/example.js
new file mode 100644
index 00000000..35b034ca
--- /dev/null
+++ b/node_modules/nanotiming/example.js
@@ -0,0 +1,21 @@
+var nanotiming = require('./')
+
+try {
+ var hooks = require('perf_hooks')
+ var nanot = nanotiming('my-loop') // Start profiling
+} catch (e) {
+ console.log('perf_hooks not available, exiting')
+ process.exit(1)
+}
+var performance = hooks.performance
+
+var i = 10
+while (--i) console.log(i)
+
+// Stop profiling
+nanot()
+
+var timings = performance.getEntries()
+var timing = timings[timings.length - 1]
+console.log(timing.name, timing.duration) // log the last entry
+performance.clearMeasures(timing.name) // be a good citizen and free after use
diff --git a/node_modules/nanotiming/index.js b/node_modules/nanotiming/index.js
new file mode 100644
index 00000000..baeef69c
--- /dev/null
+++ b/node_modules/nanotiming/index.js
@@ -0,0 +1,45 @@
+var assert = require('assert')
+
+var perf
+nanotiming.disabled = true
+try {
+ perf = require('perf_hooks').performance
+ nanotiming.disabled = process.env.DISABLE_NANOTIMING || !perf.mark
+} catch (e) { }
+
+module.exports = nanotiming
+
+function nanotiming (name) {
+ if (typeof window !== 'undefined') return require('./browser.js')(name) // electron suport
+
+ assert.equal(typeof name, 'string', 'nanotiming: name should be type string')
+
+ if (nanotiming.disabled) return noop
+
+ var uuid = (perf.now() * 10000).toFixed() % Number.MAX_SAFE_INTEGER
+ var startName = 'start-' + uuid + '-' + name
+ perf.mark(startName)
+
+ function end (cb) {
+ var endName = 'end-' + uuid + '-' + name
+ perf.mark(endName)
+
+ var err = null
+ try {
+ var measureName = name + ' [' + uuid + ']'
+ perf.measure(measureName, startName, endName)
+ perf.clearMarks(startName)
+ perf.clearMarks(endName)
+ } catch (e) { err = e }
+ if (cb) cb(err, name)
+ }
+
+ end.uuid = uuid
+ return end
+}
+
+function noop (cb) {
+ if (cb) {
+ cb(new Error('nanotiming: performance API unavailable'))
+ }
+}
diff --git a/node_modules/nanotiming/package.json b/node_modules/nanotiming/package.json
new file mode 100644
index 00000000..019bb013
--- /dev/null
+++ b/node_modules/nanotiming/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "nanotiming",
+ "description": "Small timing library",
+ "repository": "choojs/nanotiming",
+ "version": "7.3.1",
+ "main": "index.js",
+ "browser": {
+ "./index.js": "./browser.js",
+ "assert": "nanoassert"
+ },
+ "scripts": {
+ "start": "node .",
+ "test": "standard",
+ "coverage": "nyc report --reporter=text-lcov > coverage.lcov"
+ },
+ "dependencies": {
+ "nanoassert": "^1.1.0",
+ "nanoscheduler": "^1.0.2"
+ },
+ "devDependencies": {
+ "dependency-check": "^2.8.0",
+ "nyc": "^10.2.0",
+ "standard": "^10.0.1",
+ "tape": "^4.6.3"
+ },
+ "keywords": [
+ "browser",
+ "timing",
+ "mark",
+ "measure",
+ "performance"
+ ],
+ "license": "MIT"
+}