-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is to leverage console.timeStamp to add a single marker to browsers' (Only Chromium and Firefox support it) performance tool. With this support, we can dump both CPU and GPU timestamps, and use post-processing tool to clearly understand the calibrated timeline. A demo tool can be found at https://github.com/webatintel/ort-test, and more detailed info can be found at https://docs.google.com/document/d/1TuVxjE8jnELBXdhI4QGFgMnUqQn6Q53QA9y4a_dH688/edit.
- Loading branch information
Yang Gu
committed
Dec 25, 2023
1 parent
9dd9461
commit 5a9ddea
Showing
8 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import {env} from './env-impl.js'; | ||
|
||
export const TRACE = (deviceType: string, label: string) => { | ||
if (!env.wasm.trace) { | ||
return; | ||
} | ||
// eslint-disable-next-line no-console | ||
console.timeStamp(`${deviceType}::ORT::${label}`); | ||
}; | ||
|
||
const TRACE_FUNC = (msg: string, extraMsg?: string) => { | ||
const stack = new Error().stack?.split(/\r\n|\r|\n/g) || []; | ||
let hasTraceFunc = false; | ||
for (let i = 0; i < stack.length; i++) { | ||
if (hasTraceFunc && !stack[i].includes('TRACE_FUNC')) { | ||
let label = `FUNC_${msg}::${stack[i].trim().split(' ')[1]}`; | ||
if (extraMsg) { | ||
label += `::${extraMsg}`; | ||
} | ||
TRACE('CPU', label); | ||
return; | ||
} | ||
if (stack[i].includes('TRACE_FUNC')) { | ||
hasTraceFunc = true; | ||
} | ||
} | ||
}; | ||
|
||
export const TRACE_FUNC_BEGIN = (extraMsg?: string) => { | ||
if (!env.wasm.trace) { | ||
return; | ||
} | ||
TRACE_FUNC('BEGIN', extraMsg); | ||
}; | ||
|
||
export const TRACE_FUNC_END = (extraMsg?: string) => { | ||
if (!env.wasm.trace) { | ||
return; | ||
} | ||
TRACE_FUNC('END', extraMsg); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters