Skip to content

Commit

Permalink
Measure site updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jp7677 committed Nov 16, 2022
1 parent ffa766f commit c3b3ce5
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions src/main/kotlin/nl/avisi/structurizr/site/generatr/ServeCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import java.time.Duration
import kotlin.io.path.extension
import kotlin.io.path.isDirectory
import kotlin.io.path.isRegularFile
import kotlin.system.measureTimeMillis

class ServeCommand : Subcommand("serve", "Start a development server") {
private val workspaceFile by option(
Expand Down Expand Up @@ -62,27 +63,29 @@ class ServeCommand : Subcommand("serve", "Start a development server") {
val exportDir = File(siteDir, branch)

try {
broadcast("site-updating")
val workspace = createStructurizrWorkspace(File(workspaceFile))
println("Generating diagrams...")
generateDiagrams(workspace, exportDir)

println("Generating site...")
copySiteWideAssets(File(siteDir))
generateRedirectingIndexPage(File(siteDir), branch)
generateSite(
"0.0.0",
workspace,
assetsDir?.let { File(it) },
File(siteDir),
listOf(branch),
branch,
serving = true
)

updateSiteError = null
broadcast("site-updated")
println("Successfully generated diagrams and site")
val ms = measureTimeMillis {
broadcast("site-updating")
val workspace = createStructurizrWorkspace(File(workspaceFile))
println("Generating diagrams...")
generateDiagrams(workspace, exportDir)

println("Generating site...")
copySiteWideAssets(File(siteDir))
generateRedirectingIndexPage(File(siteDir), branch)
generateSite(
"0.0.0",
workspace,
assetsDir?.let { File(it) },
File(siteDir),
listOf(branch),
branch,
serving = true
)

updateSiteError = null
broadcast("site-updated")
}
println("Successfully generated diagrams and site in ${ms.toDouble() / 1000} seconds")
} catch (e: Exception) {
updateSiteError = e.message ?: "Unknown error"
broadcast(updateSiteError!!)
Expand Down

0 comments on commit c3b3ce5

Please sign in to comment.