forked from NVIDIA/spark-rapids
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NVIDIA#11062 for nvliyuan:0612-base-local (#16)
* with call site print, not good because some test cases by design will dup Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * done Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * add file Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * fix comiple Signed-off-by: Hongbin Ma (Mahone) <[email protected]> * address review comments Signed-off-by: Hongbin Ma (Mahone) <[email protected]> --------- Signed-off-by: Hongbin Ma (Mahone) <[email protected]>
- Loading branch information
Showing
3 changed files
with
106 additions
and
10 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
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
68 changes: 68 additions & 0 deletions
68
tests/src/test/scala/com/nvidia/spark/rapids/MetricsSuite.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,68 @@ | ||
/* | ||
* Copyright (c) 2024, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.nvidia.spark.rapids | ||
|
||
import ai.rapids.cudf.NvtxColor | ||
import com.nvidia.spark.rapids.Arm.withResource | ||
import org.scalatest.funsuite.AnyFunSuite | ||
|
||
class MetricsSuite extends AnyFunSuite { | ||
|
||
test("GpuMetric.ns: duplicate timing on the same metrics") { | ||
val m1 = new LocalGpuMetric() | ||
m1.ns( | ||
m1.ns( | ||
Thread.sleep(100) | ||
) | ||
) | ||
// if the timing is duplicated, the value should be around 200,000,000 | ||
assert(m1.value < 100000000 * 1.5) | ||
assert(m1.value > 100000000 * 0.5) | ||
} | ||
|
||
test("MetricRange: duplicate timing on the same metrics") { | ||
val m1 = new LocalGpuMetric() | ||
val m2 = new LocalGpuMetric() | ||
withResource(new MetricRange(m1, m2)) { _ => | ||
withResource(new MetricRange(m2, m1)) { _ => | ||
Thread.sleep(100) | ||
} | ||
} | ||
|
||
// if the timing is duplicated, the value should be around 200,000,000 | ||
assert(m1.value < 100000000 * 1.5) | ||
assert(m1.value > 100000000 * 0.5) | ||
assert(m2.value < 100000000 * 1.5) | ||
assert(m2.value > 100000000 * 0.5) | ||
} | ||
|
||
test("NvtxWithMetrics: duplicate timing on the same metrics") { | ||
val m1 = new LocalGpuMetric() | ||
val m2 = new LocalGpuMetric() | ||
withResource(new NvtxWithMetrics("a", NvtxColor.BLUE, m1, m2)) { _ => | ||
withResource(new NvtxWithMetrics("b", NvtxColor.BLUE, m2, m1)) { _ => | ||
Thread.sleep(100) | ||
} | ||
} | ||
|
||
// if the timing is duplicated, the value should be around 200,000,000 | ||
assert(m1.value < 100000000 * 1.5) | ||
assert(m1.value > 100000000 * 0.5) | ||
assert(m2.value < 100000000 * 1.5) | ||
assert(m2.value > 100000000 * 0.5) | ||
} | ||
} |