public void TestQuerySimpleTrippleStressTiming() { PreTest.Init(); Log log = new Log("Test streaming database"); log.EnableTrace = true; IXStreamDatabase db = new MyCaffeStreamDatabase(log); try { string strSchema = "ConnectionCount=3;"; string strParam = "Connection=TestCon;Table=TestTbl;Field=TestField;"; strParam = ParamPacker.Pack(strParam); strSchema += "Connection0_CustomQueryName=Test1;"; strSchema += "Connection0_CustomQueryParam=" + strParam + ";"; strSchema += "Connection1_CustomQueryName=Test2;"; strSchema += "Connection1_CustomQueryParam=" + strParam + ";"; strSchema += "Connection2_CustomQueryName=Test3;"; strSchema += "Connection2_CustomQueryParam=" + strParam + ";"; ((MyCaffeStreamDatabase)db).AddDirectQuery(new CustomQuery1()); ((MyCaffeStreamDatabase)db).AddDirectQuery(new CustomQuery2()); ((MyCaffeStreamDatabase)db).AddDirectQuery(new CustomQuery3()); DateTime dt = DateTime.Today; string strSettings = "QueryCount=5;Start=" + dt.ToShortDateString() + ";TimeSpanInMs=60000;SegmentSize=1;MaxCount=10;"; db.Initialize(QUERY_TYPE.SYNCHRONIZED, strSchema + strSettings); int[] rgSize = db.QuerySize(); log.CHECK(rgSize != null, "The Query size should not be null."); log.CHECK_EQ(rgSize.Length, 3, "The query size should have 3 items."); log.CHECK_EQ(rgSize[0], 1, "The query size item 0 should be 1."); log.CHECK_EQ(rgSize[1], 6, "The query size item 1 should be 3 for three fields (q1:sync,data; q2:data)."); log.CHECK_EQ(rgSize[2], 5, "The query size item 2 should be 5 for the number of items queried."); int nDataIdx = 0; int nH = rgSize[1]; int nW = rgSize[2]; int nCount = nH * nW; List <SimpleDatum> rgSd = new List <SimpleDatum>(); Stopwatch sw = new Stopwatch(); int nIter = 10000; sw.Start(); for (int i = 0; i < nIter; i++) { rgSd.Add(db.Query(int.MaxValue)); } sw.Stop(); double dfMs = sw.Elapsed.TotalMilliseconds; double dfMsPerQuery = dfMs / nIter; log.WriteLine("Total Time = " + dfMs.ToString() + " ms, Ave time per query = " + dfMsPerQuery.ToString() + " ms."); for (int i = 0; i < rgSd.Count; i++) { SimpleDatum sd = rgSd[i]; log.CHECK(sd != null, "The SD returned should not be null."); log.CHECK_EQ(sd.ItemCount, nCount, "There should be " + rgSize[1].ToString() + "x" + rgSize[2].ToString() + " items in the data."); log.CHECK_EQ(sd.Channels, rgSize[0], "The channels are not as expected."); log.CHECK_EQ(sd.Height, rgSize[1], "The height is not as expected."); log.CHECK_EQ(sd.Width, rgSize[2], "The width is not as expected."); for (int j = 0; j < nW; j++) { DateTime dt1 = Utility.ConvertTimeFromMinutes(sd.GetDataAtD(j)); log.CHECK(dt1 == dt, "The time sync is incorrect."); dt += TimeSpan.FromMinutes(1); double df1 = sd.GetDataAtD((nW * 1) + j); int nVal1 = (int)df1; log.CHECK_EQ(nVal1, nDataIdx, "The data value is incorrect."); double df2 = sd.GetDataAtD((nW * 2) + j); int nVal2 = (int)df2; log.CHECK_EQ(nVal2, nDataIdx, "The data value is incorrect."); double df3 = sd.GetDataAtD((nW * 3) + j); int nVal3 = (int)df3; log.CHECK_EQ(nVal3, nDataIdx, "The data value is incorrect."); double df4 = sd.GetDataAtD((nW * 4) + j); int nVal4 = (int)df4; log.CHECK_EQ(nVal4, nDataIdx, "The data value is incorrect."); double df5 = sd.GetDataAtD((nW * 5) + j); int nVal5 = (int)df5; log.CHECK_EQ(nVal5, nDataIdx, "The data value is incorrect."); nDataIdx++; } } } finally { db.Shutdown(); } }