IMPALA-5688: Reduce run-time of a couple of expr-test heavy-hitters
Two tests (LongReverse and the base64 tests in StringFunctions)
run their tests over all lengths from 0..{{some length}}. Both take
several minutes to complete. This adds a lot of runtime for not much
more confidence.
Pick a set of 'interesting' (including powers-of-two, prime numbers,
edge-cases) lengths to run them over instead. Test time is reduced by
>150s on my desktop machine in debug mode.
Change-Id: I2962115734aff8dcaae0cc405274765105e31572
Reviewed-on: http://gerrit.cloudera.org:8080/7474
Reviewed-by: Henry Robinson <[email protected]>
Tested-by: Impala Public Jenkins
Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/1653419b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/1653419b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/1653419b
Branch: refs/heads/master
Commit: 1653419bd8b3748bbc0e3d5e7ffa1d412bc4b50f
Parents: ed73244
Author: Henry Robinson <[email protected]>
Authored: Thu Jul 20 10:52:34 2017 -0700
Committer: Impala Public Jenkins <[email protected]>
Committed: Sat Jul 22 04:11:39 2017 +0000
----------------------------------------------------------------------
be/src/exprs/expr-test.cc | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/1653419b/be/src/exprs/expr-test.cc
----------------------------------------------------------------------
diff --git a/be/src/exprs/expr-test.cc b/be/src/exprs/expr-test.cc
index 3b33c47..1e3366f 100644
--- a/be/src/exprs/expr-test.cc
+++ b/be/src/exprs/expr-test.cc
@@ -3331,9 +3331,9 @@ TEST_F(ExprTest, StringFunctions) {
big_str[ColumnType::MAX_VARCHAR_LENGTH] = '\0';
sprintf(query, "cast('%sxxx' as VARCHAR(%d))", big_str,
ColumnType::MAX_VARCHAR_LENGTH);
TestStringValue(query, big_str);
+}
- // base64{en,de}code
-
+TEST_F(ExprTest, StringBase64Coding) {
// Test some known values of base64{en,de}code
TestIsNull("base64encode(NULL)", TYPE_STRING);
TestIsNull("base64decode(NULL)", TYPE_STRING);
@@ -3348,12 +3348,12 @@ TEST_F(ExprTest, StringFunctions) {
// Test random short strings.
srand(0);
- for (int length = 1; length < 100; ++length) {
+ // Pick some 'interesting' (i.e. random, but include some powers of two,
some primes,
+ // and edge-cases) lengths to test.
+ for (int length: {1, 2, 3, 5, 8, 32, 42, 50, 64, 71, 89, 99}) {
for (int iteration = 0; iteration < 10; ++iteration) {
string raw(length, ' ');
- for (int j = 0; j < length; ++j) {
- raw[j] = rand() % 128;
- }
+ for (int j = 0; j < length; ++j) raw[j] = rand() % 128;
const string as_octal = StringToOctalLiteral(raw);
TestValue("length(base64encode('" + as_octal + "')) > length('" +
as_octal + "')",
TYPE_BOOLEAN, true);
@@ -3366,7 +3366,9 @@ TEST_F(ExprTest, StringFunctions) {
TEST_F(ExprTest, LongReverse) {
static const int MAX_LEN = 2048;
string to_reverse(MAX_LEN, ' '), reversed(MAX_LEN, ' ');
- for (int i = 0; i < MAX_LEN; ++i) {
+ // Pick some 'interesting' (i.e. random, but include some powers of two,
some primes,
+ // and edge-cases) lengths to test.
+ for (int i: {1, 2, 3, 5, 8, 32, 42, 512, 1024, 1357, 1788, 2012, 2047}) {
to_reverse[i] = reversed[MAX_LEN - 1 - i] = 'a' + (rand() % 26);
TestStringValue("reverse('" + to_reverse.substr(0, i + 1) + "')",
reversed.substr(MAX_LEN - 1 - i));