traceperf 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/README.md +79 -31
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -132,15 +132,88 @@ const customTracker = createTracePerf({
132
132
 
133
133
  ## Browser Support
134
134
 
135
- TracePerf includes a browser-compatible version:
135
+ TracePerf provides a fully synchronized browser implementation that matches the Node.js API:
136
136
 
137
137
  ```javascript
138
- import traceperf from 'traceperf/browser';
138
+ import { createTracePerf, BrowserLogger } from 'traceperf/browser';
139
139
 
140
- // Use the same API as in Node.js
141
- traceperf.track(() => {
142
- // Your code
140
+ // Create a browser-optimized instance
141
+ const browserTracker = createTracePerf({
142
+ logger: new BrowserLogger({
143
+ silent: false,
144
+ trackMemory: true
145
+ })
143
146
  });
147
+
148
+ // Track function execution
149
+ browserTracker.track(() => {
150
+ // Your browser-side code
151
+ }, { label: 'browserOperation' });
152
+
153
+ // Create trackable functions
154
+ const trackedFn = browserTracker.createTrackable(() => {
155
+ // Function implementation
156
+ }, { label: 'trackedBrowserFn' });
157
+
158
+ // Track async operations
159
+ await browserTracker.track(async () => {
160
+ const response = await fetch('/api/data');
161
+ return response.json();
162
+ }, { label: 'fetchData' });
163
+ ```
164
+
165
+ You can also use it via script tag:
166
+
167
+ ```html
168
+ <script src="dist/traceperf.browser.js"></script>
169
+ <script>
170
+ const { createTracePerf, BrowserLogger } = TracePerf;
171
+
172
+ const browserTracker = createTracePerf({
173
+ logger: new BrowserLogger({
174
+ silent: false,
175
+ trackMemory: true
176
+ })
177
+ });
178
+
179
+ // Use the same API as in Node.js
180
+ browserTracker.track(() => {
181
+ // DOM operations or other browser-side logic
182
+ }, { label: 'domOperation' });
183
+ </script>
184
+ ```
185
+
186
+ ## Synchronized Features
187
+
188
+ TracePerf now provides a consistent API across Node.js and browser environments:
189
+
190
+ - **Unified Tracking API**: The same tracking methods work identically in both environments
191
+ - **Consistent Configuration**: Logger and tracker options are synchronized
192
+ - **Memory Tracking**: Both environments support memory usage tracking
193
+ - **Performance Optimization**: Browser-specific optimizations while maintaining API compatibility
194
+ - **Execution Flow**: Track complex execution flows consistently across environments
195
+
196
+ Example of cross-environment usage:
197
+
198
+ ```javascript
199
+ // Node.js
200
+ const { createTracePerf } = require('traceperf');
201
+ const nodeTracker = createTracePerf();
202
+
203
+ // Browser
204
+ import { createTracePerf } from 'traceperf/browser';
205
+ const browserTracker = createTracePerf();
206
+
207
+ // Both environments support the same API
208
+ async function trackOperation(tracker) {
209
+ return await tracker.track(async () => {
210
+ const result = await someAsyncOperation();
211
+ return processResult(result);
212
+ }, {
213
+ label: 'mainOperation',
214
+ trackMemory: true
215
+ });
216
+ }
144
217
  ```
145
218
 
146
219
  ## Examples
@@ -293,29 +366,4 @@ tracker.track(slowFunction, { threshold: 50 });
293
366
  // Different thresholds for different functions
294
367
  tracker.track(criticalFunction, { threshold: 10 }); // Low threshold for critical paths
295
368
  tracker.track(backgroundTask, { threshold: 200 }); // Higher threshold for background tasks
296
- ```
297
-
298
- ### Memory Tracking
299
-
300
- ```javascript
301
- const { createTracePerf } = require('traceperf');
302
- const tracker = createTracePerf({ trackMemory: true });
303
-
304
- // Track memory usage for memory-intensive operations
305
- const result = tracker.track(() => {
306
- // Memory-intensive operations
307
- const largeArray = new Array(1000000).fill(Math.random());
308
- return processArray(largeArray);
309
- }, { label: 'memoryIntensiveOperation' });
310
- ```
311
-
312
- For more examples, see the example files in the `examples/` directory.
313
-
314
- ## License
315
-
316
- MIT
317
-
318
- ## Website
319
-
320
- Visit our website at [traceperf.com](https://traceperf.com) for more information, interactive examples, and detailed documentation.
321
-
369
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "traceperf",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "High-performance function execution tracking and monitoring for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",