summaryrefslogtreecommitdiff
path: root/src/base/stats/mysql.cc
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2006-06-11 22:01:34 -0400
committerNathan Binkert <binkertn@umich.edu>2006-06-11 22:01:34 -0400
commit3c95f5958fd1a90cf83d85e1b24fb700c07bae91 (patch)
treeff0fba54297f66dd8e5ef7cbb46d09d8698ee08b /src/base/stats/mysql.cc
parent4ab8e881edecd47ae3f2ba5fda345f7ff9788870 (diff)
parent7af93dbdf6c86a915b99da1688f51dc12e7aafff (diff)
downloadgem5-3c95f5958fd1a90cf83d85e1b24fb700c07bae91.tar.xz
Merge iceaxe.:/Volumes/work/research/m5/head
into iceaxe.:/Volumes/work/research/m5/merge src/cpu/simple/base.cc: src/kern/kernel_stats.cc: src/kern/kernel_stats.hh: src/kern/system_events.cc: src/kern/system_events.hh: src/python/m5/objects/System.py: src/sim/system.cc: src/sim/system.hh: hand merge --HG-- rename : build/SConstruct => SConstruct rename : SConscript => src/SConscript rename : arch/alpha/freebsd/system.cc => src/arch/alpha/freebsd/system.cc rename : arch/alpha/linux/system.cc => src/arch/alpha/linux/system.cc rename : arch/alpha/linux/system.hh => src/arch/alpha/linux/system.hh rename : arch/alpha/system.cc => src/arch/alpha/system.cc rename : arch/alpha/tru64/system.cc => src/arch/alpha/tru64/system.cc rename : base/statistics.cc => src/base/statistics.cc rename : base/statistics.hh => src/base/statistics.hh rename : base/stats/mysql.cc => src/base/stats/mysql.cc rename : base/stats/mysql.hh => src/base/stats/mysql.hh rename : base/stats/statdb.cc => src/base/stats/statdb.cc rename : base/stats/statdb.hh => src/base/stats/statdb.hh rename : base/stats/text.cc => src/base/stats/text.cc rename : base/stats/text.hh => src/base/stats/text.hh rename : cpu/simple/cpu.cc => src/cpu/simple/base.cc rename : kern/kernel_stats.cc => src/kern/kernel_stats.cc rename : kern/kernel_stats.hh => src/kern/kernel_stats.hh rename : kern/system_events.cc => src/kern/system_events.cc rename : kern/system_events.hh => src/kern/system_events.hh rename : python/m5/objects/System.py => src/python/m5/objects/System.py rename : sim/system.cc => src/sim/system.cc rename : sim/system.hh => src/sim/system.hh rename : test/stattest.cc => src/unittest/stattest.cc extra : convert_revision : 4bb576a2bf5e32784efc48030bd776c6c7c29a7c
Diffstat (limited to 'src/base/stats/mysql.cc')
-rw-r--r--src/base/stats/mysql.cc96
1 files changed, 11 insertions, 85 deletions
diff --git a/src/base/stats/mysql.cc b/src/base/stats/mysql.cc
index fa4bcd5ee..0fb31f4ce 100644
--- a/src/base/stats/mysql.cc
+++ b/src/base/stats/mysql.cc
@@ -158,14 +158,6 @@ MySqlRun::cleanup()
if (mysql.commit())
panic("could not commit transaction\n%s\n", mysql.error);
- mysql.query("DELETE bins "
- "FROM bins "
- "LEFT JOIN data ON bn_id=dt_bin "
- "WHERE dt_bin IS NULL");
-
- if (mysql.commit())
- panic("could not commit transaction\n%s\n", mysql.error);
-
mysql.query("DELETE events"
"FROM events"
"LEFT JOIN runs ON ev_run=rn_id"
@@ -309,52 +301,6 @@ SetupStat::setup()
return statid;
}
-unsigned
-SetupBin(const string &bin)
-{
- static map<string, int> binmap;
-
- using namespace MySQL;
- map<string,int>::const_iterator i = binmap.find(bin);
- if (i != binmap.end())
- return (*i).second;
-
- Connection &mysql = MySqlDB.conn();
- assert(mysql.connected());
-
- uint16_t bin_id;
-
- stringstream select;
- stringstream insert;
- ccprintf(select, "SELECT bn_id FROM bins WHERE bn_name=\"%s\"", bin);
-
- mysql.query(select);
- MySQL::Result result = mysql.store_result();
- if (result) {
- assert(result.num_fields() == 1);
- MySQL::Row row = result.fetch_row();
- if (row) {
- to_number(row[0], bin_id);
- goto exit;
- }
- }
-
- ccprintf(insert, "INSERT INTO bins(bn_name) values(\"%s\")", bin);
-
- mysql.query(insert);
- if (mysql.error)
- panic("could not get a bin\n%s\n", mysql.error);
-
- bin_id = mysql.insert_id();
- if (mysql.commit())
- panic("could not commit transaction\n%s\n", mysql.error);
-
- binmap.insert(make_pair(bin, bin_id));
-
- exit:
- return bin_id;
-}
-
InsertData::InsertData()
{
query = new char[maxsize + 1];
@@ -384,7 +330,7 @@ InsertData::flush()
size = 0;
first = true;
strcpy(query, "INSERT INTO "
- "data(dt_stat,dt_x,dt_y,dt_run,dt_tick,dt_bin,dt_data) "
+ "data(dt_stat,dt_x,dt_y,dt_run,dt_tick,dt_data) "
"values");
size = strlen(query);
}
@@ -402,9 +348,9 @@ InsertData::insert()
first = false;
- size += sprintf(query + size, "(%u,%d,%d,%u,%llu,%u,\"%f\")",
+ size += sprintf(query + size, "(%u,%d,%d,%u,%llu,\"%f\")",
stat, x, y, MySqlDB.run(), (unsigned long long)tick,
- bin, data);
+ data);
}
struct InsertSubData
@@ -656,29 +602,6 @@ MySql::configure(const FormulaData &data)
InsertFormula(find(data.id), data.str());
}
-void
-MySql::output(MainBin *bin)
-{
- MySQL::Connection &mysql = MySqlDB.conn();
-
- if (bin) {
- bin->activate();
- newdata.bin = SetupBin(bin->name());
- } else {
- newdata.bin = 0;
- }
-
- Database::stat_list_t::const_iterator i, end = Database::stats().end();
- for (i = Database::stats().begin(); i != end; ++i) {
- StatData *stat = *i;
- if (bin && stat->binned() || !bin && !stat->binned()) {
- stat->visit(*this);
- if (mysql.commit())
- panic("could not commit transaction\n%s\n", mysql.error);
- }
- }
-}
-
bool
MySql::valid() const
{
@@ -697,11 +620,14 @@ MySql::output()
// store sample #
newdata.tick = curTick;
- output(NULL);
- if (!bins().empty()) {
- bin_list_t::iterator i, end = bins().end();
- for (i = bins().begin(); i != end; ++i)
- output(*i);
+ MySQL::Connection &mysql = MySqlDB.conn();
+
+ Database::stat_list_t::const_iterator i, end = Database::stats().end();
+ for (i = Database::stats().begin(); i != end; ++i) {
+ StatData *stat = *i;
+ stat->visit(*this);
+ if (mysql.commit())
+ panic("could not commit transaction\n%s\n", mysql.error);
}
newdata.flush();