LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
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 
13 QTEST_GUILESS_MAIN (LC::Util::OralTest_SimpleRecord_Bench)
14 
15 namespace LC
16 {
17 namespace 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 
37  QBENCHMARK
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 
62  QBENCHMARK
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 }
LC::Util::MakeDatabase
QSqlDatabase MakeDatabase(const QString &name=":memory:")
Definition: common.h:73
common.h
oraltest_simplerecord_bench.h
simplerecord.h
LC::Util::OralTest_SimpleRecord_Bench
Definition: oraltest_simplerecord_bench.h:29
LC::Util::oral::InsertAction::Ignore
static struct LC::Util::oral::InsertAction::IgnoreTag Ignore
LC
Definition: constants.h:14