-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More consistent usage of cost center in causal profiler
- Loading branch information
1 parent
79a2867
commit ea82649
Showing
10 changed files
with
121 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
zio-profiling-tagging-plugin-tests/src/test/scala/zio/profiling/BaseSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package zio.profiling | ||
|
||
import zio.test._ | ||
import zio.{Runtime, ZLayer} | ||
|
||
abstract class BaseSpec extends ZIOSpecDefault { | ||
override val bootstrap: ZLayer[Any, Any, TestEnvironment] = testEnvironment ++ Runtime.removeDefaultLoggers | ||
} |
34 changes: 34 additions & 0 deletions
34
...g-tagging-plugin-tests/src/test/scala/zio/profiling/causal/PluginCausalProfilerSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package zio.profiling.causal | ||
|
||
import zio._ | ||
import zio.profiling.{BaseSpec, CostCenter, ProfilerExamples} | ||
import zio.test.Assertion.isTrue | ||
import zio.test._ | ||
|
||
object PluginSamplingProfilerSpec extends BaseSpec { | ||
|
||
def spec = suite("PluginCausalProfiler")( | ||
test("Should correctly profile simple example program") { | ||
val profiler = CausalProfiler( | ||
iterations = 10, | ||
warmUpPeriod = 0.seconds, | ||
minExperimentDuration = 1.second, | ||
experimentTargetSamples = 1 | ||
) | ||
val program = (ProfilerExamples.zioProgram *> CausalProfiler.progressPoint("done")).forever | ||
Live.live(profiler.profile(program)).map { result => | ||
println(result) | ||
|
||
def isSlowEffect(location: CostCenter) = | ||
location.hasParentMatching("zio\\.profiling\\.ProfilerExamples\\.slow\\(.*\\)".r) | ||
def isFastEffect(location: CostCenter) = | ||
location.hasParentMatching("zio\\.profiling\\.ProfilerExamples\\.fast\\(.*\\)".r) | ||
|
||
val hasSlow = result.experiments.exists(e => isSlowEffect(e.selected)) | ||
val hasFast = result.experiments.exists(e => isFastEffect(e.selected)) | ||
|
||
assert(hasSlow)(isTrue) && assert(hasFast)(isTrue) | ||
} | ||
} | ||
) | ||
} |
6 changes: 3 additions & 3 deletions
6
...gging-plugin-tests/src/test/scala/zio/profiling/sampling/PluginSamplingProfilerSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package zio.profiling | ||
|
||
import zio.test.ZIOSpecDefault | ||
import zio.test._ | ||
import zio.{Runtime, ZLayer} | ||
|
||
abstract class BaseSpec extends ZIOSpecDefault | ||
abstract class BaseSpec extends ZIOSpecDefault { | ||
override val bootstrap: ZLayer[Any, Any, TestEnvironment] = testEnvironment ++ Runtime.removeDefaultLoggers | ||
} |