LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
oraltest_simplerecord_bench.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
10#include "common.h"
11#include "simplerecord.h"
12
14
15namespace LC
16{
17namespace Util
18{
19 namespace sph = oral::sph;
20
21 void OralTest_SimpleRecord_Bench::benchSimpleRecordAdapt ()
22 {
23 auto db = MakeDatabase ();
24 Util::oral::Adapt<SimpleRecord, OralFactory> (db);
25
26 QBENCHMARK { Util::oral::Adapt<SimpleRecord> (db); }
27 }
28
29 void OralTest_SimpleRecord_Bench::benchBaselineInsert ()
30 {
31 auto db = MakeDatabase ();
32 Util::oral::Adapt<SimpleRecord, OralFactory> (db);
33
34 QSqlQuery query { db };
35 query.prepare ("INSERT OR IGNORE INTO SimpleRecord (ID, Value) VALUES (:id, :val);");
36
38 {
39 query.bindValue (":id", 0);
40 query.bindValue (":val", "0");
41 query.exec ();
42 }
43 }
44
45 void OralTest_SimpleRecord_Bench::benchSimpleRecordInsert ()
46 {
47 auto db = MakeDatabase ();
48 const auto& adapted = Util::oral::Adapt<SimpleRecord, OralFactory> (db);
49
50 QBENCHMARK { adapted.Insert ({ 0, "0" }, lco::InsertAction::Ignore); }
51 }
52
53 void OralTest_SimpleRecord_Bench::benchBaselineUpdate ()
54 {
55 auto db = MakeDatabase ();
56 const auto& adapted = Util::oral::Adapt<SimpleRecord, OralFactory> (db);
57 adapted.Insert ({ 0, "0" });
58
59 QSqlQuery query { db };
60 query.prepare ("UPDATE SimpleRecord SET Value = :val WHERE Id = :id;");
61
63 {
64 query.bindValue (":id", 0);
65 query.bindValue (":val", "1");
66 query.exec ();
67 }
68 }
69
70 void OralTest_SimpleRecord_Bench::benchSimpleRecordUpdate ()
71 {
72 auto db = MakeDatabase ();
73 auto adapted = Util::oral::Adapt<SimpleRecord, OralFactory> (db);
74 adapted.Insert ({ 0, "0" });
75
76 QBENCHMARK { adapted.Update ({ 0, "1" }); }
77 }
78}
79}
Container< T > Filter(const Container< T > &c, F f)
Definition prelude.h:118
QSqlDatabase MakeDatabase(const QString &name=":memory:")
Definition common.h:73
Definition constants.h:15