@libp2p/perf 1.1.13 → 1.1.14-f4fac961

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,3 @@
1
- # @libp2p/perf <!-- omit in toc -->
2
-
3
1
  [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
4
2
  [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
5
3
  [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)
@@ -7,39 +5,58 @@
7
5
 
8
6
  > Implementation of Perf Protocol
9
7
 
10
- ## Table of contents <!-- omit in toc -->
8
+ # About
9
+
10
+ The `performanceService` implements the [perf protocol](https://github.com/libp2p/specs/blob/master/perf/perf.md), which is used to measure performance within and across libp2p implementations
11
+ addresses.
11
12
 
12
- - [Install](#install)
13
- - [Browser `<script>` tag](#browser-script-tag)
14
- - [API Docs](#api-docs)
15
- - [License](#license)
16
- - [Contribution](#contribution)
13
+ ## Example
17
14
 
18
- ## Install
15
+ ```typescript
16
+ import { createLibp2p } from 'libp2p'
17
+ import { perfService } from '@libp2p/perf'
19
18
 
20
- ```console
21
- $ npm i @libp2p/perf
19
+ const node = await createLibp2p({
20
+ service: [
21
+ perfService()
22
+ ]
23
+ })
22
24
  ```
23
25
 
24
- ### Browser `<script>` tag
26
+ The `measurePerformance` function can be used to measure the latency and throughput of a connection.
27
+ server. This will not work in browsers.
28
+
29
+ ## Example
30
+
31
+ ```typescript
32
+ import { createLibp2p } from 'libp2p'
33
+ import { perfService } from 'libp2p/perf'
34
+
35
+ const node = await createLibp2p({
36
+ services: [
37
+ perf: perfService()
38
+ ]
39
+ })
40
+
41
+ const connection = await node.dial(multiaddr(multiaddrAddress))
42
+
43
+ const startTime = Date.now()
25
44
 
26
- Loading this module through a script tag will make it's exports available as `Libp2pPerf` in the global namespace.
45
+ await node.services.perf.measurePerformance(startTime, connection, BigInt(uploadBytes), BigInt(downloadBytes))
27
46
 
28
- ```html
29
- <script src="https://unpkg.com/@libp2p/perf/dist/index.min.js"></script>
30
47
  ```
31
48
 
32
- ## API Docs
49
+ # API Docs
33
50
 
34
51
  - <https://libp2p.github.io/js-libp2p/modules/_libp2p_perf.html>
35
52
 
36
- ## License
53
+ # License
37
54
 
38
55
  Licensed under either of
39
56
 
40
57
  - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
41
58
  - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
42
59
 
43
- ## Contribution
60
+ # Contribution
44
61
 
45
62
  Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/perf",
3
- "version": "1.1.13",
3
+ "version": "1.1.14-f4fac961",
4
4
  "description": "Implementation of Perf Protocol",
5
5
  "author": "@maschad / @marcopolo",
6
6
  "license": "Apache-2.0 OR MIT",
@@ -50,16 +50,16 @@
50
50
  "dependencies": {
51
51
  "@chainsafe/libp2p-noise": "^13.0.0",
52
52
  "@chainsafe/libp2p-yamux": "^5.0.0",
53
- "@libp2p/crypto": "^2.0.6",
54
- "@libp2p/interface": "^0.1.4",
55
- "@libp2p/interface-compliance-tests": "^4.1.2",
56
- "@libp2p/interface-internal": "^0.1.7",
53
+ "@libp2p/crypto": "2.0.7-f4fac961",
54
+ "@libp2p/interface": "0.1.5-f4fac961",
55
+ "@libp2p/interface-compliance-tests": "4.1.3-f4fac961",
56
+ "@libp2p/interface-internal": "0.1.8-f4fac961",
57
57
  "@libp2p/interfaces": "3.3.2",
58
- "@libp2p/logger": "^3.0.4",
59
- "@libp2p/peer-id-factory": "^3.0.6",
60
- "@libp2p/tcp": "^8.0.10",
58
+ "@libp2p/logger": "3.0.5-f4fac961",
59
+ "@libp2p/peer-id-factory": "3.0.7-f4fac961",
60
+ "@libp2p/tcp": "8.0.11-f4fac961",
61
61
  "@multiformats/multiaddr": "^12.1.5",
62
- "libp2p": "^0.46.16",
62
+ "libp2p": "0.46.17-f4fac961",
63
63
  "uint8arrays": "^4.0.6",
64
64
  "yargs": "^17.7.2"
65
65
  },
@@ -1,12 +0,0 @@
1
- {
2
- "PerfService": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_perf.PerfService.html",
3
- ".:PerfService": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_perf.PerfService.html",
4
- "PerfServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_perf.PerfServiceComponents.html",
5
- ".:PerfServiceComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_perf.PerfServiceComponents.html",
6
- "PerfServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_perf.PerfServiceInit.html",
7
- ".:PerfServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_perf.PerfServiceInit.html",
8
- "defaultInit": "https://libp2p.github.io/js-libp2p/variables/_libp2p_perf.defaultInit.html",
9
- ".:defaultInit": "https://libp2p.github.io/js-libp2p/variables/_libp2p_perf.defaultInit.html",
10
- "perfService": "https://libp2p.github.io/js-libp2p/functions/_libp2p_perf.perfService-1.html",
11
- ".:perfService": "https://libp2p.github.io/js-libp2p/functions/_libp2p_perf.perfService-1.html"
12
- }