Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
fdfd3ad7
Commit
fdfd3ad7
authored
7 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
added user-timing to mol-task
parent
b45a3cf7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-task/execution/observable.ts
+5
-1
5 additions, 1 deletion
src/mol-task/execution/observable.ts
src/mol-task/util/user-timing.ts
+23
-0
23 additions, 0 deletions
src/mol-task/util/user-timing.ts
with
28 additions
and
1 deletion
src/mol-task/execution/observable.ts
+
5
−
1
View file @
fdfd3ad7
/**
* Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2017
-2018
mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
*/
...
...
@@ -9,6 +9,7 @@ import { RuntimeContext } from './runtime-context'
import
{
Progress
}
from
'
./progress
'
import
{
now
}
from
'
../util/now
'
import
{
Scheduler
}
from
'
../util/scheduler
'
import
{
UserTiming
}
from
'
../util/user-timing
'
interface
ExposedTask
<
T
>
extends
Task
<
T
>
{
f
:
(
ctx
:
RuntimeContext
)
=>
Promise
<
T
>
,
...
...
@@ -91,9 +92,12 @@ function snapshotProgress(info: ProgressInfo): Progress {
}
async
function
execute
<
T
>
(
task
:
ExposedTask
<
T
>
,
ctx
:
ObservableRuntimeContext
)
{
UserTiming
.
markStart
(
task
)
ctx
.
node
.
progress
.
startedTime
=
now
();
try
{
const
ret
=
await
task
.
f
(
ctx
);
UserTiming
.
markEnd
(
task
)
UserTiming
.
measure
(
task
)
if
(
ctx
.
info
.
abortToken
.
abortRequested
)
{
abort
(
ctx
.
info
,
ctx
.
node
);
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-task/util/user-timing.ts
0 → 100644
+
23
−
0
View file @
fdfd3ad7
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import
{
Task
}
from
'
../task
'
const
hasPerformance
=
typeof
performance
!==
'
undefined
'
export
namespace
UserTiming
{
function
startMarkName
(
task
:
Task
<
any
>
)
{
return
`startTask
${
task
.
id
}
`
}
function
endMarkName
(
task
:
Task
<
any
>
)
{
return
`endTask
${
task
.
id
}
`
}
export
function
markStart
(
task
:
Task
<
any
>
)
{
if
(
hasPerformance
)
performance
.
mark
(
startMarkName
(
task
))
}
export
function
markEnd
(
task
:
Task
<
any
>
)
{
if
(
hasPerformance
)
performance
.
mark
(
endMarkName
(
task
))
}
export
function
measure
(
task
:
Task
<
any
>
)
{
if
(
hasPerformance
)
performance
.
measure
(
task
.
name
,
startMarkName
(
task
),
endMarkName
(
task
))
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment