-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better performance and feedback #171
Changes from 1 commit
d7f2978
3177259
30f1c19
23bdd3d
c86986d
9e36101
e4e44a3
9fdc80e
05c9bc8
306a6a3
a027ce3
1699388
3bf52db
942ad49
8fbeb39
08048e6
10cd055
e2000da
6c8ba43
56b6929
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,6 @@ data class PipelineConfig( | |
val parser: ParserConfig, | ||
val filters: List<FilterConfig> = emptyList(), | ||
@SerialName("label") val labelExtractor: LabelExtractorConfig, | ||
val storage: StorageConfig | ||
val storage: StorageConfig, | ||
val performance: PerformanceConfig = defaultPerformanceConfig | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we use yet another config object? Maybe we can set the number of threads directly in this config? |
||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import astminer.parse.getParsingResultFactory | |
import astminer.pipeline.branch.FilePipelineBranch | ||
import astminer.pipeline.branch.FunctionPipelineBranch | ||
import astminer.pipeline.branch.IllegalLabelExtractorException | ||
import me.tongfei.progressbar.ProgressBar | ||
import java.io.File | ||
|
||
/** | ||
|
@@ -44,6 +45,7 @@ class Pipeline(private val config: PipelineConfig) { | |
* Runs the pipeline that is defined in the [config]. | ||
*/ | ||
fun run() { | ||
println("Working in ${config.performance.numOfThreads}") | ||
for (language in config.parser.languages) { | ||
println("Parsing $language") | ||
val parsingResultFactory = getParsingResultFactory(language, config.parser.name) | ||
|
@@ -52,15 +54,19 @@ class Pipeline(private val config: PipelineConfig) { | |
val files = getProjectFilesWithExtension(inputDirectory, language.fileExtension) | ||
println("${files.size} files retrieved") | ||
|
||
val progressBar = ProgressBar("", files.size.toLong()) | ||
|
||
createStorage(language).use { storage -> | ||
synchronized(storage) { | ||
parsingResultFactory.parseFilesAsync(files) { parseResult -> | ||
parsingResultFactory.parseFilesInThreads(files, config.performance.numOfThreads) { parseResult -> | ||
for (labeledResult in branch.process(parseResult)) { | ||
storage.store(labeledResult) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK, you can update progress bar here |
||
progressBar.step() | ||
} | ||
} | ||
} | ||
progressBar.close() | ||
} | ||
println("Done!") | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use
ceil(files.size / numOfThreads)
. This is more accurate (the case is taken into account if it is divided entirely), as well as more readable (here I had to hang up, why are you +1 doing)