-
Notifications
You must be signed in to change notification settings - Fork 526
[SYSTEMDS-3823] Compression test case for bultin kmeans #2194
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
|
|
||
| import static org.junit.Assert.fail; | ||
|
|
||
| import java.io.ByteArrayOutputStream; | ||
| import java.io.File; | ||
|
|
||
| import org.apache.commons.logging.Log; | ||
|
|
@@ -46,6 +47,7 @@ public class WorkloadAlgorithmTest extends AutomatedTestBase { | |
| private final static String TEST_NAME5 = "WorkloadAnalysisSliceFinder"; | ||
| private final static String TEST_NAME6 = "WorkloadAnalysisLmCG"; | ||
| private final static String TEST_NAME7 = "WorkloadAnalysisL2SVM"; | ||
| private final static String TEST_NAME8 = "WorkloadAnalysisKmeans"; | ||
| private final static String TEST_DIR = "functions/compress/workload/"; | ||
| private final static String TEST_CLASS_DIR = TEST_DIR + WorkloadAnalysisTest.class.getSimpleName() + "/"; | ||
|
|
||
|
|
@@ -73,6 +75,7 @@ public void setUp() { | |
| addTestConfiguration(TEST_NAME5, new TestConfiguration(dir, TEST_NAME5, new String[] {"B"})); | ||
| addTestConfiguration(TEST_NAME6, new TestConfiguration(dir, TEST_NAME6, new String[] {"B"})); | ||
| addTestConfiguration(TEST_NAME7, new TestConfiguration(dir, TEST_NAME7, new String[] {"B"})); | ||
| addTestConfiguration(TEST_NAME8, new TestConfiguration(dir, TEST_NAME8, new String[] {"B"})); | ||
| } | ||
|
|
||
| @Test | ||
|
|
@@ -143,8 +146,23 @@ public void testL2SVMCP() { | |
| runWorkloadAnalysisTest(TEST_NAME7, ExecMode.SINGLE_NODE, 2, false); | ||
| } | ||
|
|
||
| @Test | ||
| public void testKmeansSuccessfulCP() { | ||
| runWorkloadAnalysisTest(TEST_NAME8, ExecMode.SINGLE_NODE, 1, false, 30); | ||
| } | ||
|
|
||
| @Test | ||
| public void testKmeansUnsuccessfulCP() { | ||
| runWorkloadAnalysisTest(TEST_NAME8, ExecMode.SINGLE_NODE, 1, false, 10); | ||
| } | ||
|
|
||
| private void runWorkloadAnalysisTest(String testname, ExecMode mode, int compressionCount, boolean intermediates){ | ||
| runWorkloadAnalysisTest(testname, mode, compressionCount, intermediates, -1); | ||
| } | ||
|
|
||
| // private void runWorkloadAnalysisTest(String testname, ExecMode mode, int compressionCount) { | ||
| private void runWorkloadAnalysisTest(String testname, ExecMode mode, int compressionCount, boolean intermediates) { | ||
| private void runWorkloadAnalysisTest(String testname, ExecMode mode, int compressionCount, boolean intermediates, | ||
| int maxIter) { | ||
| ExecMode oldPlatform = setExecMode(mode); | ||
| boolean oldIntermediates = WorkloadAnalyzer.ALLOW_INTERMEDIATE_CANDIDATES; | ||
|
|
||
|
|
@@ -154,19 +172,21 @@ private void runWorkloadAnalysisTest(String testname, ExecMode mode, int compres | |
|
|
||
| String HOME = SCRIPT_DIR + TEST_DIR; | ||
| fullDMLScriptName = HOME + testname + ".dml"; | ||
| programArgs = new String[] {"-stats", "20", "-args", input("X"), input("y"), output("B")}; | ||
| programArgs = new String[] {"-stats", "20", "-args", input("X"), input("y"), output("B"), | ||
| String.valueOf(maxIter)}; | ||
|
|
||
| writeInputMatrixWithMTD("X", X, false); | ||
| writeInputMatrixWithMTD("y", y, false); | ||
|
|
||
| String ret = runTest(null).toString(); | ||
| ByteArrayOutputStream out = runTest(null); | ||
| String ret = out != null ? out.toString() : ""; | ||
| LOG.debug(ret); | ||
|
|
||
| // check various additional expectations | ||
| long actualCompressionCount = (mode == ExecMode.HYBRID || mode == ExecMode.SINGLE_NODE) ? Statistics | ||
| .getCPHeavyHitterCount("compress") : Statistics.getCPHeavyHitterCount("sp_compress"); | ||
|
|
||
| Assert.assertEquals("Assert that the compression counts expeted matches actual: " + compressionCount + " vs " | ||
| System.out.println(actualCompressionCount); | ||
|
Contributor
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. remove System out. |
||
| Assert.assertEquals("Assert that the compression counts expected matches actual: " + compressionCount + " vs " | ||
| + actualCompressionCount, compressionCount, actualCompressionCount); | ||
| if(compressionCount > 0) | ||
| Assert.assertTrue(mode == ExecMode.SINGLE_NODE || mode == ExecMode.HYBRID ? heavyHittersContainsString( | ||
|
|
@@ -176,6 +196,7 @@ private void runWorkloadAnalysisTest(String testname, ExecMode mode, int compres | |
|
|
||
| } | ||
| catch(Exception e) { | ||
| e.printStackTrace(); | ||
| resetExecMode(oldPlatform); | ||
| fail("Failed workload test"); | ||
| } | ||
|
|
||
31 changes: 31 additions & 0 deletions
31
src/test/scripts/functions/compress/workload/WorkloadAnalysisKmeans.dml
This file contains hidden or 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,31 @@ | ||
| #------------------------------------------------------------- | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you 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. | ||
| # | ||
| #------------------------------------------------------------- | ||
|
|
||
| X = read($1); | ||
|
|
||
|
|
||
| print("") | ||
| print("kmeans") | ||
|
|
||
| [data, Centering, ScaleFactor] = scale(X, TRUE, TRUE) | ||
| # terminates with result | ||
| [Y_n, C_n] = kmeans(X=data, k=16, runs= 1, max_iter=as.integer($4), eps= 1e-17, seed= 13, is_verbose=TRUE) | ||
| print(sum(Y_n)) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
add a string to the decompress command to indicate what is causing the decompression.