|
|
@@ -81,8 +81,8 @@ function isKeypress(userEventType: string | undefined) {
|
|
|
}
|
|
|
|
|
|
export function dispatchTimer(): {
|
|
|
- start: (tr: Transaction) => void
|
|
|
- end: (tr: Transaction, view: EditorView) => void
|
|
|
+ start: (trs: readonly Transaction[]) => void
|
|
|
+ end: (trs: readonly Transaction[], view: EditorView) => void
|
|
|
} {
|
|
|
if (!performanceOptionsSupport) {
|
|
|
return { start: () => {}, end: () => {} }
|
|
|
@@ -92,34 +92,45 @@ export function dispatchTimer(): {
|
|
|
let keypressesSinceDomUpdateCount = 0
|
|
|
const unpaintedKeypressStartTimes: number[] = []
|
|
|
|
|
|
- const start = (tr: Transaction) => {
|
|
|
- const userEventType = tr.annotation(Transaction.userEvent)
|
|
|
+ const start = (trs: readonly Transaction[]) => {
|
|
|
+ const keypressStart = performance.now()
|
|
|
|
|
|
- if (isKeypress(userEventType)) {
|
|
|
- unpaintedKeypressStartTimes.push(performance.now())
|
|
|
- }
|
|
|
+ trs.forEach(tr => {
|
|
|
+ const userEventType = tr.annotation(Transaction.userEvent)
|
|
|
+
|
|
|
+ if (isKeypress(userEventType)) {
|
|
|
+ unpaintedKeypressStartTimes.push(keypressStart)
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
performance.mark(TIMER_START_NAME)
|
|
|
}
|
|
|
|
|
|
- const end = (tr: Transaction, view: EditorView) => {
|
|
|
+ const end = (trs: readonly Transaction[], view: EditorView) => {
|
|
|
performance.mark(TIMER_END_NAME)
|
|
|
|
|
|
- const userEventType = tr.annotation(Transaction.userEvent)
|
|
|
+ let anyInputOrDelete = false
|
|
|
|
|
|
- if (isInputOrDelete(userEventType)) {
|
|
|
- ++userEventsSinceDomUpdateCount
|
|
|
+ trs.forEach(tr => {
|
|
|
+ const userEventType = tr.annotation(Transaction.userEvent)
|
|
|
|
|
|
- if (isKeypress(userEventType)) {
|
|
|
- ++keypressesSinceDomUpdateCount
|
|
|
- }
|
|
|
+ if (isInputOrDelete(userEventType)) {
|
|
|
+ anyInputOrDelete = true
|
|
|
+ ++userEventsSinceDomUpdateCount
|
|
|
|
|
|
- performance.measure(TIMER_MEASURE_NAME, {
|
|
|
- start: TIMER_START_NAME,
|
|
|
- end: TIMER_END_NAME,
|
|
|
- detail: { userEventType, userEventsSinceDomUpdateCount },
|
|
|
- })
|
|
|
+ if (isKeypress(userEventType)) {
|
|
|
+ ++keypressesSinceDomUpdateCount
|
|
|
+ }
|
|
|
+
|
|
|
+ performance.measure(TIMER_MEASURE_NAME, {
|
|
|
+ start: TIMER_START_NAME,
|
|
|
+ end: TIMER_END_NAME,
|
|
|
+ detail: { userEventType, userEventsSinceDomUpdateCount },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
+ if (anyInputOrDelete) {
|
|
|
// The `key` property ensures that the measurement task is only run once
|
|
|
// per measure phase
|
|
|
view.requestMeasure({
|
|
|
@@ -144,7 +155,7 @@ export function dispatchTimer(): {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- latestDocLength = tr.state.doc.length
|
|
|
+ latestDocLength = trs[trs.length - 1].state.doc.length
|
|
|
}
|
|
|
|
|
|
return { start, end }
|