<commit_before>#include <tntdb/connect.h>
#include <tntdb/result.h>
#include <tntdb/value.h>
#include <cxxtools/arg.h>
#include <cxxtools/hirestime.h>

int main(int argc, char* argv[])
{
  try
  {
    cxxtools::Arg<bool> prepared(argc, argv, 'p');
    cxxtools::Arg<bool> cached(argc, argv, 'c');

    tntdb::Connection conn = tntdb::connect("mysql:db=DS2;user=web;passwd=<PASSWORD>");
    unsigned max = conn.selectValue("select max(PROD_ID) from PRODUCTS")
                       .getUnsigned();

    cxxtools::HiresTime t0 = cxxtools::HiresTime::gettimeofday();

    unsigned sum = 0;
    if (cached)
    {
      for (unsigned n = 1; n < max; ++n)
      {
        tntdb::Statement stmt = conn.prepareCached(
          "select CATEGORY from PRODUCTS where PROD_ID = :prodId");
        stmt.set("prodId", n);
        sum += stmt.selectValue().getUnsigned();
      }
    }
    else if (prepared)
    {
      tntdb::Statement stmt = conn.prepare(
        "select CATEGORY from PRODUCTS where PROD_ID = :prodId");
      for (unsigned n = 1; n < max; ++n)
      {
        stmt.set("prodId", n);
        sum += stmt.selectValue().getUnsigned();
      }
    }
    else
    {
      for (unsigned n = 1; n < max; ++n)
      {
        tntdb::Statement stmt = conn.prepare(
          "select CATEGORY from PRODUCTS where PROD_ID = :prodId");
        stmt.set("prodId", n);
        sum += stmt.selectValue().getUnsigned();
      }
    }

    cxxtools::HiresTime t1 = cxxtools::HiresTime::gettimeofday();

    std::cout << "count=" << max << "\n"
                 "sum=" << sum << "\n"
                 "t=" << (t1 - t0) << std::endl;

  }
  catch (const std::exception& e)
  {
    std::cerr << e.what() << std::endl;
  }
}<commit_msg>update for new cxxtools<commit_after>#include <tntdb/connect.h>
#include <tntdb/result.h>
#include <tntdb/value.h>
#include <cxxtools/arg.h>
#include <cxxtools/timespan.h>

int main(int argc, char* argv[])
{
  try
  {
    cxxtools::Arg<bool> prepared(argc, argv, 'p');
    cxxtools::Arg<bool> cached(argc, argv, 'c');

    tntdb::Connection conn = tntdb::connect("mysql:db=DS2;user=web;passwd=<PASSWORD>");
    unsigned max = conn.selectValue("select max(PROD_ID) from PRODUCTS")
                       .getUnsigned();

    cxxtools::Timespan t0 = cxxtools::Timespan::gettimeofday();

    unsigned sum = 0;
    if (cached)
    {
      for (unsigned n = 1; n < max; ++n)
      {
        tntdb::Statement stmt = conn.prepareCached(
          "select CATEGORY from PRODUCTS where PROD_ID = :prodId");
        stmt.set("prodId", n);
        sum += stmt.selectValue().getUnsigned();
      }
    }
    else if (prepared)
    {
      tntdb::Statement stmt = conn.prepare(
        "select CATEGORY from PRODUCTS where PROD_ID = :prodId");
      for (unsigned n = 1; n < max; ++n)
      {
        stmt.set("prodId", n);
        sum += stmt.selectValue().getUnsigned();
      }
    }
    else
    {
      for (unsigned n = 1; n < max; ++n)
      {
        tntdb::Statement stmt = conn.prepare(
          "select CATEGORY from PRODUCTS where PROD_ID = :prodId");
        stmt.set("prodId", n);
        sum += stmt.selectValue().getUnsigned();
      }
    }

    cxxtools::Timespan t1 = cxxtools::Timespan::gettimeofday();

    std::cout << "count=" << max << "\n"
                 "sum=" << sum << "\n"
                 "t=" << (t1 - t0) << std::endl;

  }
  catch (const std::exception& e)
  {
    std::cerr << e.what() << std::endl;
  }
}
{'fraction_non_alphanumeric': 0.1673906747755575, 'fraction_numerical': 0.005212858384013901, 'mean_word_length': 2.4063116370808677, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4978030', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1233, 'n_words': 263}