summaryrefslogtreecommitdiffstats
path: root/tests/dummyresourcebenchmark.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dummyresourcebenchmark.cpp')
-rw-r--r--tests/dummyresourcebenchmark.cpp92
1 files changed, 6 insertions, 86 deletions
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp
index 674d4d6..57ad4de 100644
--- a/tests/dummyresourcebenchmark.cpp
+++ b/tests/dummyresourcebenchmark.cpp
@@ -74,10 +74,13 @@ private slots:
74 74
75 // Wait for notification 75 // Wait for notification
76 QUICK_TRY_VERIFY(gotNotification); 76 QUICK_TRY_VERIFY(gotNotification);
77 HAWD::Dataset dataset("dummy_responsiveness", m_hawdState);
78 HAWD::Dataset::Row row = dataset.row();
79 row.setValue("responsetime", duration);
80 dataset.insertRow(row);
81 HAWD::Formatter::print(dataset);
77 82
78 QVERIFY2(duration < 100, QString::fromLatin1("Processing a create command took more than 100ms: %1").arg(duration).toLatin1());
79 VERIFYEXEC(Sink::ResourceControl::shutdown("sink.dummy.instance1")); 83 VERIFYEXEC(Sink::ResourceControl::shutdown("sink.dummy.instance1"));
80 qDebug() << "Single command took [ms]: " << duration;
81 } 84 }
82 85
83 void testWriteToFacade() 86 void testWriteToFacade()
@@ -113,12 +116,6 @@ private slots:
113 row.setValue("total", (qreal)num / allProcessedTime); 116 row.setValue("total", (qreal)num / allProcessedTime);
114 dataset.insertRow(row); 117 dataset.insertRow(row);
115 HAWD::Formatter::print(dataset); 118 HAWD::Formatter::print(dataset);
116
117 auto diskUsage = DummyResource::diskUsage("sink.dummy.instance1");
118 qDebug() << "Database size [kb]: " << diskUsage / 1024;
119
120 // Print memory layout, RSS is what is in memory
121 // std::system("exec pmap -x \"$PPID\"");
122 } 119 }
123 120
124 void testQueryByUid() 121 void testQueryByUid()
@@ -133,7 +130,7 @@ private slots:
133 130
134 query.filter("uid", Sink::Query::Comparator("testuid")); 131 query.filter("uid", Sink::Query::Comparator("testuid"));
135 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); 132 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query);
136 QTRY_COMPARE(model->rowCount(QModelIndex()), num); 133 QUICK_TRY_VERIFY(model->rowCount(QModelIndex()) == num);
137 } 134 }
138 auto queryTime = time.elapsed(); 135 auto queryTime = time.elapsed();
139 136
@@ -145,83 +142,6 @@ private slots:
145 HAWD::Formatter::print(dataset); 142 HAWD::Formatter::print(dataset);
146 } 143 }
147 144
148 void testWriteInProcess()
149 {
150 VERIFYEXEC(Sink::Store::removeDataFromDisk("sink.dummy.instance1"));
151 QTime time;
152 time.start();
153
154 DummyResource resource(Sink::ResourceContext{"sink.dummy.instance1", "sink.dummy", Sink::AdaptorFactoryRegistry::instance().getFactories("sink.dummy")});
155
156 flatbuffers::FlatBufferBuilder eventFbb;
157 eventFbb.Clear();
158 {
159 auto summary = eventFbb.CreateString("summary");
160 Sink::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb);
161 eventBuilder.add_summary(summary);
162 auto eventLocation = eventBuilder.Finish();
163 Sink::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation);
164 }
165
166 flatbuffers::FlatBufferBuilder localFbb;
167 {
168 auto uid = localFbb.CreateString("testuid");
169 auto localBuilder = Sink::ApplicationDomain::Buffer::EventBuilder(localFbb);
170 localBuilder.add_uid(uid);
171 auto location = localBuilder.Finish();
172 Sink::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location);
173 }
174
175 flatbuffers::FlatBufferBuilder entityFbb;
176 Sink::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize());
177
178 flatbuffers::FlatBufferBuilder fbb;
179 auto type = fbb.CreateString(Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Event>().toStdString().data());
180 auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize());
181 Sink::Commands::CreateEntityBuilder builder(fbb);
182 builder.add_domainType(type);
183 builder.add_delta(delta);
184 auto location = builder.Finish();
185 Sink::Commands::FinishCreateEntityBuffer(fbb, location);
186
187 const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize());
188
189 for (int i = 0; i < num; i++) {
190 resource.processCommand(Sink::Commands::CreateEntityCommand, command);
191 }
192 auto appendTime = time.elapsed();
193
194 // Wait until all messages have been processed
195 resource.processAllMessages().exec().waitForFinished();
196
197 auto allProcessedTime = time.elapsed();
198
199
200 // Print memory layout, RSS is what is in memory
201 // std::system("exec pmap -x \"$PPID\"");
202 }
203
204 void testCreateCommand()
205 {
206 Sink::ApplicationDomain::Event event;
207
208 QBENCHMARK {
209 auto mFactory = new DummyEventAdaptorFactory;
210 static flatbuffers::FlatBufferBuilder entityFbb;
211 entityFbb.Clear();
212 mFactory->createBuffer(event, entityFbb);
213
214 static flatbuffers::FlatBufferBuilder fbb;
215 fbb.Clear();
216 // This is the resource buffer type and not the domain type
217 auto entityId = fbb.CreateString("");
218 auto type = fbb.CreateString("event");
219 // auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize());
220 auto delta = Sink::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize());
221 auto location = Sink::Commands::CreateCreateEntity(fbb, entityId, type, delta);
222 Sink::Commands::FinishCreateEntityBuffer(fbb, location);
223 }
224 }
225 145
226 // This allows to run individual parts without doing a cleanup, but still cleaning up normally 146 // This allows to run individual parts without doing a cleanup, but still cleaning up normally
227 void testCleanupForCompleteTest() 147 void testCleanupForCompleteTest()