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
9890d480
Commit
9890d480
authored
7 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
more accurate time management for Computation.Chunker
parent
9f0a9db2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-util/computation.ts
+10
-9
10 additions, 9 deletions
src/mol-util/computation.ts
src/perf-tests/structure.ts
+17
-0
17 additions, 0 deletions
src/perf-tests/structure.ts
src/script.ts
+2
-1
2 additions, 1 deletion
src/script.ts
with
29 additions
and
10 deletions
src/mol-util/computation.ts
+
10
−
9
View file @
9890d480
...
...
@@ -124,8 +124,6 @@ class ObservableContext implements Computation.Context {
private
observers
:
Computation
.
ProgressObserver
[]
|
undefined
=
void
0
;
private
progress
:
Computation
.
Progress
=
{
message
:
'
Working...
'
,
current
:
0
,
max
:
0
,
elapsedMs
:
0
,
isIndeterminate
:
true
,
requestAbort
:
void
0
};
lastDelta
=
0
;
private
checkAborted
()
{
if
(
this
.
abortRequested
)
throw
Computation
.
Aborted
;
}
...
...
@@ -186,7 +184,6 @@ class ObservableContext implements Computation.Context {
}
}
this
.
lastDelta
=
time
-
this
.
lastUpdated
;
this
.
lastUpdated
=
time
;
return
Scheduler
.
immediatePromise
();
...
...
@@ -223,11 +220,10 @@ class ChunkerImpl implements Computation.Chunker {
private
processedSinceUpdate
=
0
;
private
updater
:
Computation
.
Context
[
'
update
'
];
private
computeChunkSize
()
{
const
lastDelta
=
(
this
.
context
as
ObservableContext
).
lastDelta
||
0
;
if
(
!
lastDelta
)
return
this
.
nextChunkSize
;
private
computeChunkSize
(
delta
:
number
)
{
if
(
!
delta
)
return
this
.
nextChunkSize
;
const
rate
=
(
this
.
context
as
ObservableContext
).
updateRate
||
DefaulUpdateRateMs
;
const
ret
=
Math
.
round
(
this
.
processedSinceUpdate
*
rate
/
lastD
elta
+
1
);
const
ret
=
Math
.
round
(
this
.
processedSinceUpdate
*
rate
/
d
elta
+
1
);
this
.
processedSinceUpdate
=
0
;
return
ret
;
}
...
...
@@ -246,17 +242,22 @@ class ChunkerImpl implements Computation.Chunker {
async
process
(
nextChunk
:
(
size
:
number
)
=>
number
,
update
:
(
updater
:
Computation
.
Context
[
'
update
'
])
=>
Promise
<
void
>
|
void
,
nextChunkSize
?:
number
)
{
if
(
typeof
nextChunkSize
!==
'
undefined
'
)
this
.
setNextChunkSize
(
nextChunkSize
);
// track time for the actual computation and exclude the "update time"
let
chunkStart
=
Computation
.
now
();
let
lastChunkSize
:
number
;
while
((
lastChunkSize
=
nextChunk
(
this
.
getNextChunkSize
()))
>
0
)
{
this
.
processedSinceUpdate
+=
lastChunkSize
;
if
(
this
.
context
.
requiresUpdate
)
{
let
time
=
Computation
.
now
();
await
update
(
this
.
updater
);
this
.
nextChunkSize
=
this
.
computeChunkSize
();
this
.
nextChunkSize
=
this
.
computeChunkSize
(
time
-
chunkStart
);
chunkStart
=
Computation
.
now
();
}
}
if
(
this
.
context
.
requiresUpdate
)
{
let
time
=
Computation
.
now
();
await
update
(
this
.
updater
);
this
.
nextChunkSize
=
this
.
computeChunkSize
();
this
.
nextChunkSize
=
this
.
computeChunkSize
(
time
-
chunkStart
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/perf-tests/structure.ts
+
17
−
0
View file @
9890d480
...
...
@@ -29,6 +29,23 @@ async function readData(path: string) {
}
}
function
*
test
()
{
yield
10
;
return
15
;
}
async
function
runIt
<
T
>
(
itP
:
()
=>
IterableIterator
<
T
>
)
{
const
it
=
itP
();
let
lastValue
:
T
|
undefined
;
while
(
true
)
{
const
{
value
,
done
}
=
it
.
next
();
if
(
done
)
return
value
;
lastValue
=
value
;
}
}
runIt
(
test
).
then
(
r
=>
console
.
log
(
'
rerdasdasda
'
,
r
))
export
async
function
readCIF
(
path
:
string
)
{
console
.
time
(
'
readData
'
);
const
input
=
await
readData
(
path
)
...
...
This diff is collapsed.
Click to expand it.
src/script.ts
+
2
−
1
View file @
9890d480
...
...
@@ -148,13 +148,14 @@ async function runCIF(input: string | Uint8Array) {
export
async
function
_cif
()
{
let
path
=
`./examples/1grm_updated.cif`
;
// path = '../test/3j3q.cif' // lets have a relative path for big test files
//path = 'e:/test/quick/3j3q_updated.cif';
const
input
=
await
readFileAsync
(
path
,
'
utf8
'
)
console
.
log
(
'
------------------
'
);
console
.
log
(
'
Text CIF:
'
);
runCIF
(
input
);
path
=
`./examples/1cbs_full.bcif`
;
// const path = 'c:/test/quick/3j3q.cif';
const
input2
=
await
readFileAsync
(
path
)
console
.
log
(
'
------------------
'
);
console
.
log
(
'
BinaryCIF:
'
);
...
...
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