summaryrefslogtreecommitdiff
path: root/indra/newview/tests
diff options
context:
space:
mode:
authorMonty Brandenberg <monty@lindenlab.com>2010-12-10 17:41:05 -0800
committerMonty Brandenberg <monty@lindenlab.com>2010-12-10 17:41:05 -0800
commit11d420dd32e643a191c16b04f2fbb42c2b4db628 (patch)
treeaa9aa0be3b72c178e8fd41ea59e55d50d91590bb /indra/newview/tests
parent4bab98f5cd2a815d10fe494a0a7e51cc237adb4a (diff)
Decided to refactor a bit. Was using LLSD as an internal data
representation transferring ownership, doing data aggregation in a very pedantic way. That's just adding unneeded cost and complication. Used the same objects to transport data as are collecting it and everything got simpler, faster, easier to read with fewer gotchas. Bit myself *again* doing the min/max/mean merges but the unittests where there to pick me up again. Added a per-region FPS metric while I was at it. This is much asked for and there was a convenient place to sample the value.
Diffstat (limited to 'indra/newview/tests')
-rw-r--r--indra/newview/tests/llsimplestat_test.cpp158
-rw-r--r--indra/newview/tests/llviewerassetstats_test.cpp595
2 files changed, 518 insertions, 235 deletions
diff --git a/indra/newview/tests/llsimplestat_test.cpp b/indra/newview/tests/llsimplestat_test.cpp
index 5efc9cf857..60a8cac995 100644
--- a/indra/newview/tests/llsimplestat_test.cpp
+++ b/indra/newview/tests/llsimplestat_test.cpp
@@ -425,4 +425,162 @@ namespace tut
ensure("Overflowed MMM<U64> has huge max", (bignum == m1.getMax()));
ensure("Overflowed MMM<U64> has fetchable mean", (zero == m1.getMean() || true));
}
+
+ // Testing LLSimpleStatCounter's merge() method
+ template<> template<>
+ void stat_counter_index_object_t::test<12>()
+ {
+ LLSimpleStatCounter c1;
+ LLSimpleStatCounter c2;
+
+ ++c1;
+ ++c1;
+ ++c1;
+ ++c1;
+
+ ++c2;
+ ++c2;
+ c2.merge(c1);
+
+ ensure_equals("4 merged into 2 results in 6", 6, c2.getCount());
+
+ ensure_equals("Source of merge is undamaged", 4, c1.getCount());
+ }
+
+ // Testing LLSimpleStatMMM's merge() method
+ template<> template<>
+ void stat_counter_index_object_t::test<13>()
+ {
+ LLSimpleStatMMM<> m1;
+ LLSimpleStatMMM<> m2;
+
+ m1.record(3.5);
+ m1.record(4.5);
+ m1.record(5.5);
+ m1.record(6.5);
+
+ m2.record(5.0);
+ m2.record(7.0);
+ m2.record(9.0);
+
+ m2.merge(m1);
+
+ ensure_equals("Count after merge (p1)", 7, m2.getCount());
+ ensure_approximately_equals("Min after merge (p1)", F32(3.5), m2.getMin(), 22);
+ ensure_approximately_equals("Max after merge (p1)", F32(9.0), m2.getMax(), 22);
+ ensure_approximately_equals("Mean after merge (p1)", F32(41.000/7.000), m2.getMean(), 22);
+
+
+ ensure_equals("Source count of merge is undamaged (p1)", 4, m1.getCount());
+ ensure_approximately_equals("Source min of merge is undamaged (p1)", F32(3.5), m1.getMin(), 22);
+ ensure_approximately_equals("Source max of merge is undamaged (p1)", F32(6.5), m1.getMax(), 22);
+ ensure_approximately_equals("Source mean of merge is undamaged (p1)", F32(5.0), m1.getMean(), 22);
+
+ m2.reset();
+
+ m2.record(-22.0);
+ m2.record(-1.0);
+ m2.record(30.0);
+
+ m2.merge(m1);
+
+ ensure_equals("Count after merge (p2)", 7, m2.getCount());
+ ensure_approximately_equals("Min after merge (p2)", F32(-22.0), m2.getMin(), 22);
+ ensure_approximately_equals("Max after merge (p2)", F32(30.0), m2.getMax(), 22);
+ ensure_approximately_equals("Mean after merge (p2)", F32(27.000/7.000), m2.getMean(), 22);
+
+ }
+
+ // Testing LLSimpleStatMMM's merge() method when src contributes nothing
+ template<> template<>
+ void stat_counter_index_object_t::test<14>()
+ {
+ LLSimpleStatMMM<> m1;
+ LLSimpleStatMMM<> m2;
+
+ m2.record(5.0);
+ m2.record(7.0);
+ m2.record(9.0);
+
+ m2.merge(m1);
+
+ ensure_equals("Count after merge (p1)", 3, m2.getCount());
+ ensure_approximately_equals("Min after merge (p1)", F32(5.0), m2.getMin(), 22);
+ ensure_approximately_equals("Max after merge (p1)", F32(9.0), m2.getMax(), 22);
+ ensure_approximately_equals("Mean after merge (p1)", F32(7.000), m2.getMean(), 22);
+
+ ensure_equals("Source count of merge is undamaged (p1)", 0, m1.getCount());
+ ensure_approximately_equals("Source min of merge is undamaged (p1)", F32(0), m1.getMin(), 22);
+ ensure_approximately_equals("Source max of merge is undamaged (p1)", F32(0), m1.getMax(), 22);
+ ensure_approximately_equals("Source mean of merge is undamaged (p1)", F32(0), m1.getMean(), 22);
+
+ m2.reset();
+
+ m2.record(-22.0);
+ m2.record(-1.0);
+
+ m2.merge(m1);
+
+ ensure_equals("Count after merge (p2)", 2, m2.getCount());
+ ensure_approximately_equals("Min after merge (p2)", F32(-22.0), m2.getMin(), 22);
+ ensure_approximately_equals("Max after merge (p2)", F32(-1.0), m2.getMax(), 22);
+ ensure_approximately_equals("Mean after merge (p2)", F32(-11.5), m2.getMean(), 22);
+ }
+
+ // Testing LLSimpleStatMMM's merge() method when dst contributes nothing
+ template<> template<>
+ void stat_counter_index_object_t::test<15>()
+ {
+ LLSimpleStatMMM<> m1;
+ LLSimpleStatMMM<> m2;
+
+ m1.record(5.0);
+ m1.record(7.0);
+ m1.record(9.0);
+
+ m2.merge(m1);
+
+ ensure_equals("Count after merge (p1)", 3, m2.getCount());
+ ensure_approximately_equals("Min after merge (p1)", F32(5.0), m2.getMin(), 22);
+ ensure_approximately_equals("Max after merge (p1)", F32(9.0), m2.getMax(), 22);
+ ensure_approximately_equals("Mean after merge (p1)", F32(7.000), m2.getMean(), 22);
+
+ ensure_equals("Source count of merge is undamaged (p1)", 3, m1.getCount());
+ ensure_approximately_equals("Source min of merge is undamaged (p1)", F32(5.0), m1.getMin(), 22);
+ ensure_approximately_equals("Source max of merge is undamaged (p1)", F32(9.0), m1.getMax(), 22);
+ ensure_approximately_equals("Source mean of merge is undamaged (p1)", F32(7.0), m1.getMean(), 22);
+
+ m1.reset();
+ m2.reset();
+
+ m1.record(-22.0);
+ m1.record(-1.0);
+
+ m2.merge(m1);
+
+ ensure_equals("Count after merge (p2)", 2, m2.getCount());
+ ensure_approximately_equals("Min after merge (p2)", F32(-22.0), m2.getMin(), 22);
+ ensure_approximately_equals("Max after merge (p2)", F32(-1.0), m2.getMax(), 22);
+ ensure_approximately_equals("Mean after merge (p2)", F32(-11.5), m2.getMean(), 22);
+ }
+
+ // Testing LLSimpleStatMMM's merge() method when neither dst nor src contributes
+ template<> template<>
+ void stat_counter_index_object_t::test<16>()
+ {
+ LLSimpleStatMMM<> m1;
+ LLSimpleStatMMM<> m2;
+
+ m2.merge(m1);
+
+ ensure_equals("Count after merge (p1)", 0, m2.getCount());
+ ensure_approximately_equals("Min after merge (p1)", F32(0), m2.getMin(), 22);
+ ensure_approximately_equals("Max after merge (p1)", F32(0), m2.getMax(), 22);
+ ensure_approximately_equals("Mean after merge (p1)", F32(0), m2.getMean(), 22);
+
+ ensure_equals("Source count of merge is undamaged (p1)", 0, m1.getCount());
+ ensure_approximately_equals("Source min of merge is undamaged (p1)", F32(0), m1.getMin(), 22);
+ ensure_approximately_equals("Source max of merge is undamaged (p1)", F32(0), m1.getMax(), 22);
+ ensure_approximately_equals("Source mean of merge is undamaged (p1)", F32(0), m1.getMean(), 22);
+ }
}
diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index 153056b3cd..9c54266017 100644
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -44,6 +44,7 @@
static const char * all_keys[] =
{
"duration",
+ "fps",
"get_other",
"get_texture_temp_http",
"get_texture_temp_udp",
@@ -76,6 +77,19 @@ static const char * sub_keys[] =
"resp_mean"
};
+static const char * mmm_resp_keys[] =
+{
+ "fps"
+};
+
+static const char * mmm_sub_keys[] =
+{
+ "count",
+ "max",
+ "min",
+ "mean"
+};
+
static const LLUUID region1("4e2d81a3-6263-6ffe-ad5c-8ce04bee07e8");
static const LLUUID region2("68762cc8-b68b-4e45-854b-e830734f2d4a");
static const U64 region1_handle(0x00000401000003f7ULL);
@@ -172,6 +186,15 @@ namespace tut
ensure(line, sd[resp_keys[i]].has(sub_keys[j]));
}
}
+
+ for (int i = 0; i < LL_ARRAY_SIZE(mmm_resp_keys); ++i)
+ {
+ for (int j = 0; j < LL_ARRAY_SIZE(mmm_sub_keys); ++j)
+ {
+ std::string line = llformat("Key '%s' has '%s' key", mmm_resp_keys[i], mmm_sub_keys[j]);
+ ensure(line, sd[mmm_resp_keys[i]].has(mmm_sub_keys[j]));
+ }
+ }
}
// Create a non-global instance and check some content
@@ -461,293 +484,395 @@ namespace tut
ensure("sd[get_gesture_udp][dequeued] is reset", (0 == sd["get_gesture_udp"]["dequeued"].asInteger()));
}
- // Check that the LLSD merger knows what it's doing (basic test)
+
+ // LLViewerAssetStats::merge() basic functions work
template<> template<>
void tst_viewerassetstats_index_object_t::test<9>()
{
- LLSD::String reg1_name = region1_handle_str;
- LLSD::String reg2_name = region2_handle_str;
-
- LLSD reg1_stats = LLSD::emptyMap();
- LLSD reg2_stats = LLSD::emptyMap();
-
- LLSD & tmp_other1 = reg1_stats["get_other"];
- tmp_other1["enqueued"] = 4;
- tmp_other1["dequeued"] = 4;
- tmp_other1["resp_count"] = 8;
- tmp_other1["resp_max"] = F64(23.2892);
- tmp_other1["resp_min"] = F64(0.2829);
- tmp_other1["resp_mean"] = F64(2.298928);
-
- LLSD & tmp_other2 = reg2_stats["get_other"];
- tmp_other2["enqueued"] = 8;
- tmp_other2["dequeued"] = 7;
- tmp_other2["resp_count"] = 3;
- tmp_other2["resp_max"] = F64(6.5);
- tmp_other2["resp_min"] = F64(0.01);
- tmp_other2["resp_mean"] = F64(4.1);
+ LLViewerAssetStats s1;
+ LLViewerAssetStats s2;
+
+ s1.setRegion(region1_handle);
+ s2.setRegion(region1_handle);
+
+ s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 5000000);
+ s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 6000000);
+ s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 8000000);
+ s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 7000000);
+ s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 9000000);
- {
- LLSD src = LLSD::emptyMap();
- LLSD dst = LLSD::emptyMap();
+ s2.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 2000000);
+ s2.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 3000000);
+ s2.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 4000000);
- src["regions"][reg1_name] = reg1_stats;
- src["duration"] = 24;
- dst["regions"][reg2_name] = reg2_stats;
- dst["duration"] = 36;
+ s2.merge(s1);
- LLViewerAssetStats::mergeRegionsLLSD(src, dst);
+ LLSD s2_llsd = s2.asLLSD();
- ensure("region 1 in merged stats", llsd_equals(reg1_stats, dst["regions"][reg1_name]));
- ensure("region 2 still in merged stats", llsd_equals(reg2_stats, dst["regions"][reg2_name]));
- }
+ ensure_equals("count after merge", 8, s2_llsd["regions"][region1_handle_str]["get_texture_temp_http"]["resp_count"].asInteger());
+ ensure_approximately_equals("min after merge", 2.0, s2_llsd["regions"][region1_handle_str]["get_texture_temp_http"]["resp_min"].asReal(), 22);
+ ensure_approximately_equals("max after merge", 9.0, s2_llsd["regions"][region1_handle_str]["get_texture_temp_http"]["resp_max"].asReal(), 22);
+ ensure_approximately_equals("max after merge", 5.5, s2_llsd["regions"][region1_handle_str]["get_texture_temp_http"]["resp_mean"].asReal(), 22);
- {
- LLSD src = LLSD::emptyMap();
- LLSD dst = LLSD::emptyMap();
-
- src["regions"][reg1_name] = reg1_stats;
- src["duration"] = 24;
- dst["regions"][reg1_name] = reg2_stats;
- dst["duration"] = 36;
-
- LLViewerAssetStats::mergeRegionsLLSD(src, dst);
-
- ensure("src not ruined", llsd_equals(reg1_stats, src["regions"][reg1_name]));
- ensure_equals("added enqueued counts", dst["regions"][reg1_name]["get_other"]["enqueued"].asInteger(), 12);
- ensure_equals("added dequeued counts", dst["regions"][reg1_name]["get_other"]["dequeued"].asInteger(), 11);
- ensure_equals("added response counts", dst["regions"][reg1_name]["get_other"]["resp_count"].asInteger(), 11);
- ensure_approximately_equals("min'd minimum response times", dst["regions"][reg1_name]["get_other"]["resp_min"].asReal(), 0.01, 20);
- ensure_approximately_equals("max'd maximum response times", dst["regions"][reg1_name]["get_other"]["resp_max"].asReal(), 23.2892, 20);
- ensure_approximately_equals("weighted mean of means", dst["regions"][reg1_name]["get_other"]["resp_mean"].asReal(), 2.7901295, 20);
- }
}
- // Maximum merges are interesting when one side contributes nothing
+ // LLViewerAssetStats::merge() basic functions work without corrupting source data
template<> template<>
void tst_viewerassetstats_index_object_t::test<10>()
{
- LLSD::String reg1_name = region1_handle_str;
- LLSD::String reg2_name = region2_handle_str;
-
- LLSD reg1_stats = LLSD::emptyMap();
- LLSD reg2_stats = LLSD::emptyMap();
-
- LLSD & tmp_other1 = reg1_stats["get_other"];
- tmp_other1["enqueued"] = 4;
- tmp_other1["dequeued"] = 4;
- tmp_other1["resp_count"] = 7;
- tmp_other1["resp_max"] = F64(-23.2892);
- tmp_other1["resp_min"] = F64(-123.2892);
- tmp_other1["resp_mean"] = F64(-58.28298);
-
- LLSD & tmp_other2 = reg2_stats["get_other"];
- tmp_other2["enqueued"] = 8;
- tmp_other2["dequeued"] = 7;
- tmp_other2["resp_count"] = 0;
- tmp_other2["resp_max"] = F64(0);
- tmp_other2["resp_min"] = F64(0);
- tmp_other2["resp_mean"] = F64(0);
-
- {
- LLSD src = LLSD::emptyMap();
- LLSD dst = LLSD::emptyMap();
+ LLViewerAssetStats s1;
+ LLViewerAssetStats s2;
- src["regions"][reg1_name] = reg1_stats;
- src["duration"] = 24;
- dst["regions"][reg1_name] = reg2_stats;
- dst["duration"] = 36;
+ s1.setRegion(region1_handle);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
- LLViewerAssetStats::mergeRegionsLLSD(src, dst);
-
- ensure_approximately_equals("dst maximum with count 0 does not contribute to merged maximum",
- dst["regions"][reg1_name]["get_other"]["resp_max"].asReal(), F64(-23.2892), 20);
- }
-
- {
- LLSD src = LLSD::emptyMap();
- LLSD dst = LLSD::emptyMap();
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
- src["regions"][reg1_name] = reg2_stats;
- src["duration"] = 24;
- dst["regions"][reg1_name] = reg1_stats;
- dst["duration"] = 36;
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 23289200);
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 282900);
- LLViewerAssetStats::mergeRegionsLLSD(src, dst);
- ensure_approximately_equals("src maximum with count 0 does not contribute to merged maximum",
- dst["regions"][reg1_name]["get_other"]["resp_max"].asReal(), F64(-23.2892), 20);
- }
- }
+ s2.setRegion(region2_handle);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s2.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 6500000);
+ s2.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 10000);
- // Minimum merges are interesting when one side contributes nothing
- template<> template<>
- void tst_viewerassetstats_index_object_t::test<11>()
- {
- LLSD::String reg1_name = region1_handle_str;
- LLSD::String reg2_name = region2_handle_str;
-
- LLSD reg1_stats = LLSD::emptyMap();
- LLSD reg2_stats = LLSD::emptyMap();
-
- LLSD & tmp_other1 = reg1_stats["get_other"];
- tmp_other1["enqueued"] = 4;
- tmp_other1["dequeued"] = 4;
- tmp_other1["resp_count"] = 7;
- tmp_other1["resp_max"] = F64(123.2892);
- tmp_other1["resp_min"] = F64(23.2892);
- tmp_other1["resp_mean"] = F64(58.28298);
-
- LLSD & tmp_other2 = reg2_stats["get_other"];
- tmp_other2["enqueued"] = 8;
- tmp_other2["dequeued"] = 7;
- tmp_other2["resp_count"] = 0;
- tmp_other2["resp_max"] = F64(0);
- tmp_other2["resp_min"] = F64(0);
- tmp_other2["resp_mean"] = F64(0);
-
{
- LLSD src = LLSD::emptyMap();
- LLSD dst = LLSD::emptyMap();
-
- src["regions"][reg1_name] = reg1_stats;
- src["duration"] = 24;
- dst["regions"][reg1_name] = reg2_stats;
- dst["duration"] = 36;
+ s2.merge(s1);
+
+ LLSD src = s1.asLLSD();
+ LLSD dst = s2.asLLSD();
+
+ // Remove time stamps, they're a problem
+ src.erase("duration");
+ src["regions"][region1_handle_str].erase("duration");
+ dst.erase("duration");
+ dst["regions"][region1_handle_str].erase("duration");
+ dst["regions"][region2_handle_str].erase("duration");
+
+ ensure_equals("merge src has single region", 1, src["regions"].size());
+ ensure_equals("merge dst has dual regions", 2, dst["regions"].size());
+ ensure("result from src is in dst", llsd_equals(src["regions"][region1_handle_str],
+ dst["regions"][region1_handle_str]));
+ }
- LLViewerAssetStats::mergeRegionsLLSD(src, dst);
+ s1.setRegion(region1_handle);
+ s2.setRegion(region1_handle);
+ s1.reset();
+ s2.reset();
- ensure_approximately_equals("dst minimum with count 0 does not contribute to merged minimum",
- dst["regions"][reg1_name]["get_other"]["resp_min"].asReal(), F64(23.2892), 20);
- }
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
- {
- LLSD src = LLSD::emptyMap();
- LLSD dst = LLSD::emptyMap();
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
- src["regions"][reg1_name] = reg2_stats;
- src["duration"] = 24;
- dst["regions"][reg1_name] = reg1_stats;
- dst["duration"] = 36;
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 23289200);
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 282900);
- LLViewerAssetStats::mergeRegionsLLSD(src, dst);
- ensure_approximately_equals("src minimum with count 0 does not contribute to merged minimum",
- dst["regions"][reg1_name]["get_other"]["resp_min"].asReal(), F64(23.2892), 20);
+ s2.setRegion(region1_handle);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s2.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 6500000);
+ s2.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 10000);
+
+ {
+ s2.merge(s1);
+
+ LLSD src = s1.asLLSD();
+ LLSD dst = s2.asLLSD();
+
+ // Remove time stamps, they're a problem
+ src.erase("duration");
+ src["regions"][region1_handle_str].erase("duration");
+ dst.erase("duration");
+ dst["regions"][region1_handle_str].erase("duration");
+
+ ensure_equals("src counts okay (enq)", 4, src["regions"][region1_handle_str]["get_other"]["enqueued"].asInteger());
+ ensure_equals("src counts okay (deq)", 4, src["regions"][region1_handle_str]["get_other"]["dequeued"].asInteger());
+ ensure_equals("src resp counts okay", 2, src["regions"][region1_handle_str]["get_other"]["resp_count"].asInteger());
+ ensure_approximately_equals("src respmin okay", 0.2829, src["regions"][region1_handle_str]["get_other"]["resp_min"].asReal(), 20);
+ ensure_approximately_equals("src respmax okay", 23.2892, src["regions"][region1_handle_str]["get_other"]["resp_max"].asReal(), 20);
+
+ ensure_equals("dst counts okay (enq)", 12, dst["regions"][region1_handle_str]["get_other"]["enqueued"].asInteger());
+ ensure_equals("src counts okay (deq)", 11, dst["regions"][region1_handle_str]["get_other"]["dequeued"].asInteger());
+ ensure_equals("dst resp counts okay", 4, dst["regions"][region1_handle_str]["get_other"]["resp_count"].asInteger());
+ ensure_approximately_equals("dst respmin okay", 0.010, dst["regions"][region1_handle_str]["get_other"]["resp_min"].asReal(), 20);
+ ensure_approximately_equals("dst respmax okay", 23.2892, dst["regions"][region1_handle_str]["get_other"]["resp_max"].asReal(), 20);
}
}
- // resp_count missing is taken as '0' for maximum calculation
+
+ // Maximum merges are interesting when one side contributes nothing
template<> template<>
- void tst_viewerassetstats_index_object_t::test<12>()
+ void tst_viewerassetstats_index_object_t::test<11>()
{
- LLSD::String reg1_name = region1_handle_str;
- LLSD::String reg2_name = region2_handle_str;
-
- LLSD reg1_stats = LLSD::emptyMap();
- LLSD reg2_stats = LLSD::emptyMap();
-
- LLSD & tmp_other1 = reg1_stats["get_other"];
- tmp_other1["enqueued"] = 4;
- tmp_other1["dequeued"] = 4;
- tmp_other1["resp_count"] = 7;
- tmp_other1["resp_max"] = F64(-23.2892);
- tmp_other1["resp_min"] = F64(-123.2892);
- tmp_other1["resp_mean"] = F64(-58.28298);
-
- LLSD & tmp_other2 = reg2_stats["get_other"];
- tmp_other2["enqueued"] = 8;
- tmp_other2["dequeued"] = 7;
- // tmp_other2["resp_count"] = 0;
- tmp_other2["resp_max"] = F64(0);
- tmp_other2["resp_min"] = F64(0);
- tmp_other2["resp_mean"] = F64(0);
-
+ LLViewerAssetStats s1;
+ LLViewerAssetStats s2;
+
+ s1.setRegion(region1_handle);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ // Want to test negative numbers here but have to work in U64
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0);
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0);
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0);
+
+ s2.setRegion(region1_handle);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
{
- LLSD src = LLSD::emptyMap();
- LLSD dst = LLSD::emptyMap();
+ s2.merge(s1);
+
+ LLSD src = s1.asLLSD();
+ LLSD dst = s2.asLLSD();
- src["regions"][reg1_name] = reg1_stats;
- src["duration"] = 24;
- dst["regions"][reg1_name] = reg2_stats;
- dst["duration"] = 36;
+ // Remove time stamps, they're a problem
+ src.erase("duration");
+ src["regions"][region1_handle_str].erase("duration");
+ dst.erase("duration");
+ dst["regions"][region1_handle_str].erase("duration");
- LLViewerAssetStats::mergeRegionsLLSD(src, dst);
-
- ensure_approximately_equals("dst maximum with undefined count does not contribute to merged maximum",
- dst["regions"][reg1_name]["get_other"]["resp_max"].asReal(), F64(-23.2892), 20);
+ ensure_equals("dst counts come from src only", 3, dst["regions"][region1_handle_str]["get_other"]["resp_count"].asInteger());
+
+ ensure_approximately_equals("dst maximum with count 0 does not contribute to merged maximum",
+ dst["regions"][region1_handle_str]["get_other"]["resp_max"].asReal(), F64(0.0), 20);
}
+ // Other way around
+ s1.setRegion(region1_handle);
+ s2.setRegion(region1_handle);
+ s1.reset();
+ s2.reset();
+
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ // Want to test negative numbers here but have to work in U64
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0);
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0);
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0);
+
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
{
- LLSD src = LLSD::emptyMap();
- LLSD dst = LLSD::emptyMap();
+ s1.merge(s2);
+
+ LLSD src = s2.asLLSD();
+ LLSD dst = s1.asLLSD();
- src["regions"][reg1_name] = reg2_stats;
- src["duration"] = 24;
- dst["regions"][reg1_name] = reg1_stats;
- dst["duration"] = 36;
+ // Remove time stamps, they're a problem
+ src.erase("duration");
+ src["regions"][region1_handle_str].erase("duration");
+ dst.erase("duration");
+ dst["regions"][region1_handle_str].erase("duration");
- LLViewerAssetStats::mergeRegionsLLSD(src, dst);
-
- ensure_approximately_equals("src maximum with undefined count does not contribute to merged maximum",
- dst["regions"][reg1_name]["get_other"]["resp_max"].asReal(), F64(-23.2892), 20);
+ ensure_equals("dst counts come from src only (flipped)", 3, dst["regions"][region1_handle_str]["get_other"]["resp_count"].asInteger());
+
+ ensure_approximately_equals("dst maximum with count 0 does not contribute to merged maximum (flipped)",
+ dst["regions"][region1_handle_str]["get_other"]["resp_max"].asReal(), F64(0.0), 20);
}
}
- // resp_count unspecified is taken as 0 for minimum merges
+ // Minimum merges are interesting when one side contributes nothing
template<> template<>
- void tst_viewerassetstats_index_object_t::test<13>()
+ void tst_viewerassetstats_index_object_t::test<12>()
{
- LLSD::String reg1_name = region1.asString();
- LLSD::String reg2_name = region2.asString();
-
- LLSD reg1_stats = LLSD::emptyMap();
- LLSD reg2_stats = LLSD::emptyMap();
-
- LLSD & tmp_other1 = reg1_stats["get_other"];
- tmp_other1["enqueued"] = 4;
- tmp_other1["dequeued"] = 4;
- tmp_other1["resp_count"] = 7;
- tmp_other1["resp_max"] = F64(123.2892);
- tmp_other1["resp_min"] = F64(23.2892);
- tmp_other1["resp_mean"] = F64(58.28298);
-
- LLSD & tmp_other2 = reg2_stats["get_other"];
- tmp_other2["enqueued"] = 8;
- tmp_other2["dequeued"] = 7;
- // tmp_other2["resp_count"] = 0;
- tmp_other2["resp_max"] = F64(0);
- tmp_other2["resp_min"] = F64(0);
- tmp_other2["resp_mean"] = F64(0);
-
+ LLViewerAssetStats s1;
+ LLViewerAssetStats s2;
+
+ s1.setRegion(region1_handle);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 3800000);
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 2700000);
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 2900000);
+
+ s2.setRegion(region1_handle);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
{
- LLSD src = LLSD::emptyMap();
- LLSD dst = LLSD::emptyMap();
+ s2.merge(s1);
+
+ LLSD src = s1.asLLSD();
+ LLSD dst = s2.asLLSD();
- src["regions"][reg1_name] = reg1_stats;
- src["duration"] = 24;
- dst["regions"][reg1_name] = reg2_stats;
- dst["duration"] = 36;
+ // Remove time stamps, they're a problem
+ src.erase("duration");
+ src["regions"][region1_handle_str].erase("duration");
+ dst.erase("duration");
+ dst["regions"][region1_handle_str].erase("duration");
- LLViewerAssetStats::mergeRegionsLLSD(src, dst);
-
- ensure_approximately_equals("dst minimum with undefined count does not contribute to merged minimum",
- dst["regions"][reg1_name]["get_other"]["resp_min"].asReal(), F64(23.2892), 20);
+ ensure_equals("dst counts come from src only", 3, dst["regions"][region1_handle_str]["get_other"]["resp_count"].asInteger());
+
+ ensure_approximately_equals("dst minimum with count 0 does not contribute to merged minimum",
+ dst["regions"][region1_handle_str]["get_other"]["resp_min"].asReal(), F64(2.7), 20);
}
+ // Other way around
+ s1.setRegion(region1_handle);
+ s2.setRegion(region1_handle);
+ s1.reset();
+ s2.reset();
+
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 3800000);
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 2700000);
+ s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 2900000);
+
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+ s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+
{
- LLSD src = LLSD::emptyMap();
- LLSD dst = LLSD::emptyMap();
+ s1.merge(s2);
+
+ LLSD src = s2.asLLSD();
+ LLSD dst = s1.asLLSD();
- src["regions"][reg1_name] = reg2_stats;
- src["duration"] = 24;
- dst["regions"][reg1_name] = reg1_stats;
- dst["duration"] = 36;
+ // Remove time stamps, they're a problem
+ src.erase("duration");
+ src["regions"][region1_handle_str].erase("duration");
+ dst.erase("duration");
+ dst["regions"][region1_handle_str].erase("duration");
- LLViewerAssetStats::mergeRegionsLLSD(src, dst);
-
- ensure_approximately_equals("src minimum with undefined count does not contribute to merged minimum",
- dst["regions"][reg1_name]["get_other"]["resp_min"].asReal(), F64(23.2892), 20);
+ ensure_equals("dst counts come from src only (flipped)", 3, dst["regions"][region1_handle_str]["get_other"]["resp_count"].asInteger());
+
+ ensure_approximately_equals("dst minimum with count 0 does not contribute to merged minimum (flipped)",
+ dst["regions"][region1_handle_str]["get_other"]["resp_min"].asReal(), F64(2.7), 20);
}
}
+
}