Skip to content

Commit 33f1a29

Browse files
committed
WIP: hack around to make performance test parse incrementally
1 parent 7b3b567 commit 33f1a29

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Sources/swift-parser-cli/Commands/PerformanceTest.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import _InstructionCounter
1414
import ArgumentParser
1515
import Foundation
1616
import SwiftParser
17+
import SwiftSyntax
1718

1819
struct PerformanceTest: ParsableCommand {
1920
static var configuration = CommandConfiguration(
@@ -39,10 +40,15 @@ struct PerformanceTest: ParsableCommand {
3940

4041
let start = Date()
4142
let startInstructions = getInstructionsExecuted()
42-
for _ in 0..<self.iterations {
43+
let parseTransition = IncrementalParseTransition()
44+
var previousTreeDict: [Data:SourceFileSyntax] = [:]
45+
for iter in 0..<self.iterations {
4346
for file in files {
47+
if iter != 0 {
48+
parseTransition.setupTransition(tree: previousTreeDict[file]!, edits: ConcurrentEdits(fromSequential: []))
49+
}
4450
file.withUnsafeBytes { buf in
45-
_ = Parser.parse(source: buf.bindMemory(to: UInt8.self))
51+
previousTreeDict[file] = Parser.parse(source: buf.bindMemory(to: UInt8.self), parseTransition: parseTransition)
4652
}
4753
}
4854
}

0 commit comments

Comments
 (0)