该程序是数据库和应用程序之间的中间件.对于每个数据库访问,我大多数以毫秒为单位计算时间长度.下面的示例是使用Builder库中的TDateTime.我必须尽可能只使用标准的c ++库.
Run Code Online (Sandbox Code Playgroud)AnsiString TimeInMilliseconds(TDateTime t) { Word Hour, Min, Sec, MSec; DecodeTime(t, Hour, Min, Sec, MSec); long ms = MSec + Sec * 1000 + Min * 1000 * 60 + Hour * 1000 * 60 * 60; return IntToStr(ms); }
// computing times
TDateTime SelectStart = Now();
sql_manipulation_statement();
TDateTime SelectEnd = Now();
Run Code Online (Sandbox Code Playgroud)