diff options
Diffstat (limited to 'tests/genericresourcebenchmark.cpp')
-rw-r--r-- | tests/genericresourcebenchmark.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/genericresourcebenchmark.cpp b/tests/genericresourcebenchmark.cpp index fbe0d12..7f0d3a2 100644 --- a/tests/genericresourcebenchmark.cpp +++ b/tests/genericresourcebenchmark.cpp | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | static void removeFromDisk(const QString &name) | 21 | static void removeFromDisk(const QString &name) |
22 | { | 22 | { |
23 | Akonadi2::Storage store(Akonadi2::storageLocation(), name, Akonadi2::Storage::ReadWrite); | 23 | Sink::Storage store(Sink::storageLocation(), name, Sink::Storage::ReadWrite); |
24 | store.removeFromDisk(); | 24 | store.removeFromDisk(); |
25 | } | 25 | } |
26 | 26 | ||
@@ -30,39 +30,39 @@ static QByteArray createEntityBuffer() | |||
30 | eventFbb.Clear(); | 30 | eventFbb.Clear(); |
31 | { | 31 | { |
32 | auto summary = eventFbb.CreateString("summary"); | 32 | auto summary = eventFbb.CreateString("summary"); |
33 | Akonadi2::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb); | 33 | Sink::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb); |
34 | eventBuilder.add_summary(summary); | 34 | eventBuilder.add_summary(summary); |
35 | auto eventLocation = eventBuilder.Finish(); | 35 | auto eventLocation = eventBuilder.Finish(); |
36 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation); | 36 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation); |
37 | } | 37 | } |
38 | 38 | ||
39 | flatbuffers::FlatBufferBuilder localFbb; | 39 | flatbuffers::FlatBufferBuilder localFbb; |
40 | { | 40 | { |
41 | auto uid = localFbb.CreateString("testuid"); | 41 | auto uid = localFbb.CreateString("testuid"); |
42 | auto localBuilder = Akonadi2::ApplicationDomain::Buffer::EventBuilder(localFbb); | 42 | auto localBuilder = Sink::ApplicationDomain::Buffer::EventBuilder(localFbb); |
43 | localBuilder.add_uid(uid); | 43 | localBuilder.add_uid(uid); |
44 | auto location = localBuilder.Finish(); | 44 | auto location = localBuilder.Finish(); |
45 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); | 45 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); |
46 | } | 46 | } |
47 | 47 | ||
48 | flatbuffers::FlatBufferBuilder entityFbb; | 48 | flatbuffers::FlatBufferBuilder entityFbb; |
49 | Akonadi2::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); | 49 | Sink::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); |
50 | 50 | ||
51 | flatbuffers::FlatBufferBuilder fbb; | 51 | flatbuffers::FlatBufferBuilder fbb; |
52 | auto type = fbb.CreateString(Akonadi2::ApplicationDomain::getTypeName<Akonadi2::ApplicationDomain::Event>().toStdString().data()); | 52 | auto type = fbb.CreateString(Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Event>().toStdString().data()); |
53 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 53 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
54 | Akonadi2::Commands::CreateEntityBuilder builder(fbb); | 54 | Sink::Commands::CreateEntityBuilder builder(fbb); |
55 | builder.add_domainType(type); | 55 | builder.add_domainType(type); |
56 | builder.add_delta(delta); | 56 | builder.add_delta(delta); |
57 | auto location = builder.Finish(); | 57 | auto location = builder.Finish(); |
58 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | 58 | Sink::Commands::FinishCreateEntityBuffer(fbb, location); |
59 | 59 | ||
60 | return QByteArray(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | 60 | return QByteArray(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); |
61 | } | 61 | } |
62 | 62 | ||
63 | class IndexUpdater : public Akonadi2::Preprocessor { | 63 | class IndexUpdater : public Sink::Preprocessor { |
64 | public: | 64 | public: |
65 | void newEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 65 | void newEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
66 | { | 66 | { |
67 | for (int i = 0; i < 10; i++) { | 67 | for (int i = 0; i < 10; i++) { |
68 | Index ridIndex(QString("index.index%1").arg(i).toLatin1(), transaction); | 68 | Index ridIndex(QString("index.index%1").arg(i).toLatin1(), transaction); |
@@ -70,11 +70,11 @@ public: | |||
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | void modifiedEntity(const QByteArray &key, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 73 | void modifiedEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
74 | { | 74 | { |
75 | } | 75 | } |
76 | 76 | ||
77 | void deletedEntity(const QByteArray &key, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 77 | void deletedEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
78 | { | 78 | { |
79 | } | 79 | } |
80 | }; | 80 | }; |
@@ -89,7 +89,7 @@ private Q_SLOTS: | |||
89 | 89 | ||
90 | void init() | 90 | void init() |
91 | { | 91 | { |
92 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Warning); | 92 | Sink::Log::setDebugOutputLevel(Sink::Log::Warning); |
93 | } | 93 | } |
94 | 94 | ||
95 | void initTestCase() | 95 | void initTestCase() |
@@ -104,7 +104,7 @@ private Q_SLOTS: | |||
104 | { | 104 | { |
105 | int num = 10000; | 105 | int num = 10000; |
106 | 106 | ||
107 | auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.test.instance1"); | 107 | auto pipeline = QSharedPointer<Sink::Pipeline>::create("org.kde.test.instance1"); |
108 | TestResource resource("org.kde.test.instance1", pipeline); | 108 | TestResource resource("org.kde.test.instance1", pipeline); |
109 | 109 | ||
110 | auto command = createEntityBuffer(); | 110 | auto command = createEntityBuffer(); |
@@ -113,7 +113,7 @@ private Q_SLOTS: | |||
113 | time.start(); | 113 | time.start(); |
114 | 114 | ||
115 | for (int i = 0; i < num; i++) { | 115 | for (int i = 0; i < num; i++) { |
116 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); | 116 | resource.processCommand(Sink::Commands::CreateEntityCommand, command); |
117 | } | 117 | } |
118 | auto appendTime = time.elapsed(); | 118 | auto appendTime = time.elapsed(); |
119 | 119 | ||
@@ -139,13 +139,13 @@ private Q_SLOTS: | |||
139 | { | 139 | { |
140 | int num = 50000; | 140 | int num = 50000; |
141 | 141 | ||
142 | auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.test.instance1"); | 142 | auto pipeline = QSharedPointer<Sink::Pipeline>::create("org.kde.test.instance1"); |
143 | 143 | ||
144 | auto eventFactory = QSharedPointer<TestEventAdaptorFactory>::create(); | 144 | auto eventFactory = QSharedPointer<TestEventAdaptorFactory>::create(); |
145 | const QByteArray resourceIdentifier = "org.kde.test.instance1"; | 145 | const QByteArray resourceIdentifier = "org.kde.test.instance1"; |
146 | auto indexer = QSharedPointer<IndexUpdater>::create(); | 146 | auto indexer = QSharedPointer<IndexUpdater>::create(); |
147 | 147 | ||
148 | pipeline->setPreprocessors("event", QVector<Akonadi2::Preprocessor*>() << indexer.data()); | 148 | pipeline->setPreprocessors("event", QVector<Sink::Preprocessor*>() << indexer.data()); |
149 | pipeline->setAdaptorFactory("event", eventFactory); | 149 | pipeline->setAdaptorFactory("event", eventFactory); |
150 | 150 | ||
151 | TestResource resource("org.kde.test.instance1", pipeline); | 151 | TestResource resource("org.kde.test.instance1", pipeline); |
@@ -156,7 +156,7 @@ private Q_SLOTS: | |||
156 | time.start(); | 156 | time.start(); |
157 | 157 | ||
158 | for (int i = 0; i < num; i++) { | 158 | for (int i = 0; i < num; i++) { |
159 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); | 159 | resource.processCommand(Sink::Commands::CreateEntityCommand, command); |
160 | } | 160 | } |
161 | auto appendTime = time.elapsed(); | 161 | auto appendTime = time.elapsed(); |
162 | 162 | ||
@@ -180,7 +180,7 @@ private Q_SLOTS: | |||
180 | 180 | ||
181 | void testCreateCommand() | 181 | void testCreateCommand() |
182 | { | 182 | { |
183 | Akonadi2::ApplicationDomain::Event event; | 183 | Sink::ApplicationDomain::Event event; |
184 | 184 | ||
185 | QBENCHMARK { | 185 | QBENCHMARK { |
186 | auto mFactory = new TestEventAdaptorFactory; | 186 | auto mFactory = new TestEventAdaptorFactory; |
@@ -193,9 +193,9 @@ private Q_SLOTS: | |||
193 | //This is the resource buffer type and not the domain type | 193 | //This is the resource buffer type and not the domain type |
194 | auto type = fbb.CreateString("event"); | 194 | auto type = fbb.CreateString("event"); |
195 | // auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 195 | // auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
196 | auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 196 | auto delta = Sink::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
197 | auto location = Akonadi2::Commands::CreateCreateEntity(fbb, type, delta); | 197 | auto location = Sink::Commands::CreateCreateEntity(fbb, type, delta); |
198 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | 198 | Sink::Commands::FinishCreateEntityBuffer(fbb, location); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||