Skip to content

Commit

Permalink
measure throughput for slice sampler
Browse files Browse the repository at this point in the history
  • Loading branch information
breandan committed Oct 7, 2023
1 parent 289eedb commit 3007110
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions latex/tacas2023/preamble.tex
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@
\newcommand{\ddiagarrow}{
\tikz{
\fill (0pt,0pt) circle [radius = 1pt];
\fill (6pt,0pt) circle [radius = 1pt];
\fill (0pt,6pt) circle [radius = 1pt];
\fill (6pt,6pt) circle [radius = 1pt];
\draw [-to] (0pt,0pt) -- (6pt,6pt);
}
Expand Down
Binary file modified latex/tacas2023/tacas.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class PTree(val root: String = "ε", val branches: List<Π2A<PTree>> = listOf())
if (branches.isEmpty()) 1uL
else branches.sumOf { (l, r) -> l.totalTrees * r.totalTrees }
}
val shuffledBranches by lazy { branches.shuffled() }

private val choice by lazy {
if (branches.isEmpty()) listOf(if ("ε" in root) "" else root)
else branches.flatMap { (l, r) ->
else branches.shuffled().flatMap { (l, r) ->
// TODO: Use weighted choice mechanism
(l.choose() * r.choose()).map { (a, b) ->
if (a.isEmpty()) b else if (b.isEmpty()) a else "$a $b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,13 @@ class SetValiantTest {
detSols.forEach { assertTrue("\"$it\" was invalid!") { it in seq2parsePythonCFG.language } }
println("Found ${detSols.size} determinstic solutions, all were valid!")

val clock = TimeSource.Monotonic.markNow()
val randSols = seq2parsePythonCFG.noEpsilonOrNonterminalStubs
.sliceSample(20).take(10).toList()
.onEach { println(it); assertTrue("\"$it\" was invalid!") { it in seq2parsePythonCFG.language } }
.sliceSample(20).take(10_000).toList()
.onEach { assertTrue("\"$it\" was invalid!") { it in seq2parsePythonCFG.language } }

println("Found ${randSols.size} random solutions, all were valid!")
// 10k in ~22094ms
println("Found ${randSols.size} random solutions in ${clock.elapsedNow().inWholeMilliseconds}ms, all were valid!")
}

val seq2parsePythonCFG: CFG = """
Expand Down

0 comments on commit 3007110

Please sign in to comment.