sqlite_ubench.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include <string>
  15. #include "benchmark.h"
  16. /// @brief SQLite benchmark
  17. ///
  18. /// That is a specific backend implementation. See \ref uBenchmark class for
  19. /// detailed explanation of its operations. This class uses SQLite as DB backend.
  20. class SQLite_uBenchmark: public uBenchmark {
  21. public:
  22. /// @brief The sole SQL benchmark constructor
  23. ///
  24. /// DB file must be present and appropriate database schema must
  25. /// be used. See sqlite.schema script and isc-dhcp-perf-guide.html
  26. /// for details.
  27. ///
  28. /// sync flag affects "PRAGMA synchronous" to be ON or OFF.
  29. ///
  30. /// @param filename name of the SQLite DB file. Must be present.
  31. /// @param num_iterations number of iterations of basic lease operations
  32. /// @param sync should the operations be synchronous or not?
  33. /// @param verbose would you like extra details be logged?
  34. SQLite_uBenchmark(const std::string& filename,
  35. uint32_t num_iterations,
  36. bool sync, bool verbose);
  37. /// @brief Prints SQLite version info.
  38. virtual void printInfo();
  39. /// @brief Opens connection to the SQLite database.
  40. virtual void connect();
  41. /// @brief Closes connection to the SQLite database.
  42. virtual void disconnect();
  43. /// @brief Creates new leases.
  44. ///
  45. /// See uBenchmark::createLease4Test() for detailed explanation.
  46. virtual void createLease4Test();
  47. /// @brief Searches for existing leases.
  48. ///
  49. /// See uBenchmark::searchLease4Test() for detailed explanation.
  50. virtual void searchLease4Test();
  51. /// @brief Updates existing leases.
  52. ///
  53. /// See uBenchmark::updateLease4Test() for detailed explanation.
  54. virtual void updateLease4Test();
  55. /// @brief Deletes existing leases.
  56. ///
  57. /// See uBenchmark::deleteLease4Test() for detailed explanation.
  58. virtual void deleteLease4Test();
  59. protected:
  60. /// Handle to SQLite database connection.
  61. sqlite3 *db_;
  62. };