Thread: [PATCH] Add ElapsedTimeToString to format execution time in a more readable manner (instead of showing everything as msec)
[PATCH] Add ElapsedTimeToString to format execution time in a more readable manner (instead of showing everything as msec)
From
John Obaterspok
Date:
Add ElapsedTimeToString to format execution time in a more readable manner (instead of showing everything as msec)
Signed-off-by: John Obaterspok <john.obaterspok@gmail.com>
diff --git a/pgadmin/dlg/dlgClasses.cpp b/pgadmin/dlg/dlgClasses.cpp
index 9a3e473..e6fa488 100644
--- a/pgadmin/dlg/dlgClasses.cpp
+++ b/pgadmin/dlg/dlgClasses.cpp
@@ -562,7 +562,7 @@ void ExecutionDialog::OnOK(wxCommandEvent &ev)
{
if (txtMessages)
txtMessages->AppendText(_("Total query runtime: ")
- + (wxGetLocalTimeMillis() - startTime).ToString() + wxT(" ms."));
+ + ElapsedTimeToString(wxGetLocalTimeMillis() - startTime));
btnOK->SetLabel(_("Done"));
btnCancel->Disable();
diff --git a/pgadmin/frm/frmMain.cpp b/pgadmin/frm/frmMain.cpp
index 8629dda..94528e8 100644
--- a/pgadmin/frm/frmMain.cpp
+++ b/pgadmin/frm/frmMain.cpp
@@ -1352,9 +1352,7 @@ void frmMain::EndMsg(bool done)
{
// Get the execution time & display it
float timeval = stopwatch.Time();
- wxString time;
- time.Printf(_("%.2f secs"), (timeval / 1000));
- statusBar->SetStatusText(time, 2);
+ statusBar->SetStatusText(ElapsedTimeToString(timeval), 2);
// Display the 'Done' message
if (done)
@@ -1362,7 +1360,7 @@ void frmMain::EndMsg(bool done)
else
statusBar->SetStatusText(timermsg + _(" Failed."), 1);
- wxLogStatus(wxT("%s (%s)"), timermsg.c_str(), time.c_str());
+ wxLogStatus(wxT("%s (%s)"), timermsg.c_str(), ElapsedTimeToString(timeval).c_str());
wxEndBusyCursor();
}
}
diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cpp
index 110bbc7..6198c83 100644
--- a/pgadmin/frm/frmQuery.cpp
+++ b/pgadmin/frm/frmQuery.cpp
@@ -55,6 +55,7 @@
#include "utils/sysLogger.h"
#include "utils/sysSettings.h"
#include "utils/utffile.h"
+#include "utils/misc.h"
#include "pgscript/pgsApplication.h"
// Icons
@@ -2711,7 +2712,7 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)
msgHistory->AppendText(str);
elapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;
- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);
+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);
if (sqlResult->RunStatus() != PGRES_TUPLES_OK)
{
@@ -2724,28 +2725,28 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)
OID insertedOid = sqlResult->InsertedOid();
if (insertedCount < 0)
{
- showMessage(wxString::Format(_("Query returned successfully with no result in %s ms."),
- elapsedQuery.ToString().c_str()), _("OK."));
+ showMessage(wxString::Format(_("Query returned successfully with no result in %s."),
+ ElapsedTimeToString(elapsedQuery).c_str()), _("OK."));
}
else if (insertedCount == 1)
{
if (insertedOid)
{
- showMessage(wxString::Format(_("Query returned successfully: one row with OID %ld inserted, %s ms execution time."),
- (long)insertedOid, elapsedQuery.ToString().c_str()),
+ showMessage(wxString::Format(_("Query returned successfully: one row with OID %ld inserted, %s execution time."),
+ (long)insertedOid, ElapsedTimeToString(elapsedQuery).c_str()),
wxString::Format(_("One row with OID %ld inserted."), (long)insertedOid));
}
else
{
- showMessage(wxString::Format(_("Query returned successfully: one row affected, %s ms execution time."),
- elapsedQuery.ToString().c_str()),
+ showMessage(wxString::Format(_("Query returned successfully: one row affected, %s execution time."),
+ ElapsedTimeToString(elapsedQuery).c_str()),
wxString::Format(_("One row affected.")));
}
}
else
{
- showMessage(wxString::Format(_("Query returned successfully: %d rows affected, %s ms execution time."),
- insertedCount, elapsedQuery.ToString().c_str()),
+ showMessage(wxString::Format(_("Query returned successfully: %d rows affected, %s execution time."),
+ insertedCount, ElapsedTimeToString(elapsedQuery).c_str()),
wxString::Format(_("%d rows affected."), insertedCount));
}
}
@@ -2865,9 +2866,9 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)
sqlResult->DisplayData();
- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);
+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);
- str = _("Total query runtime: ") + elapsedQuery.ToString() + wxT(" ms.\n") ;
+ str = _("Total query runtime: ") + ElapsedTimeToString(elapsedQuery) + "\n";
msgResult->AppendText(str);
msgHistory->AppendText(str);
@@ -2952,9 +2953,10 @@ void frmQuery::OnScriptComplete(wxCommandEvent &ev)
// Manage timer
elapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;
- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);
+ wxString fmtExecTime = ElapsedTimeToString(elapsedQuery);
+ SetStatusText(fmtExecTime, STATUSPOS_SECS);
SetStatusText(_("pgScript completed."), STATUSPOS_MSGS);
- wxString str = _("Total pgScript runtime: ") + elapsedQuery.ToString() + wxT(" ms.\n\n");
+ wxString str = _("Total pgScript runtime: ") + fmtExecTime + "\n\n";
msgHistory->AppendText(str);
// Check whether there was an error/exception
@@ -3078,7 +3080,7 @@ void frmQuery::completeQuery(bool done, bool explain, bool verbose)
void frmQuery::OnTimer(wxTimerEvent &event)
{
elapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;
- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);
+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);
wxString str = sqlResult->GetMessagesAndClear();
if (!str.IsEmpty())
@@ -3088,13 +3090,22 @@ void frmQuery::OnTimer(wxTimerEvent &event)
}
// Increase the granularity for longer running queries
- if (elapsedQuery > 200 && timer.GetInterval() == 10 && timer.IsRunning())
+ if (timer.IsRunning())
{
- timer.Stop();
- timer.Start(100);
+ if (elapsedQuery > 200 && timer.GetInterval() < 100)
+ {
+ timer.Stop();
+ timer.Start(100);
+ }
+ else if (elapsedQuery > 60 * 1000 && timer.GetInterval() < 1000)
+ {
+ timer.Stop();
+ timer.Start(1000);
+ }
}
}
+
// Adjust sizes of GQB components, Located here because need to
// avoid some issues when implementing inside controller/view Classes
void frmQuery::adjustGQBSizes()
diff --git a/pgadmin/include/utils/misc.h b/pgadmin/include/utils/misc.h
index abef297..07713ae 100644
--- a/pgadmin/include/utils/misc.h
+++ b/pgadmin/include/utils/misc.h
@@ -117,6 +117,7 @@ wxString NumToStr(double value);
wxString NumToStr(OID value);
wxString NumToStr(wxLongLong value);
wxString DateToStr(const wxDateTime &datetime);
+wxString ElapsedTimeToString(wxLongLong msec);
// Quoting
diff --git a/pgadmin/utils/misc.cpp b/pgadmin/utils/misc.cpp
index b7d8afe..9a134fb 100644
--- a/pgadmin/utils/misc.cpp
+++ b/pgadmin/utils/misc.cpp
@@ -219,6 +219,28 @@ wxString DateToStr(const wxDateTime &datetime)
}
+wxString ElapsedTimeToString(wxLongLong msec)
+{
+ wxTimeSpan tsMsec(0, 0, 0, msec);
+
+ int days = tsMsec.GetDays();
+ int hours = (wxTimeSpan(tsMsec.GetHours(), 0, 0, 0) - wxTimeSpan(days * 24)).GetHours();
+ int minutes = (wxTimeSpan(0, tsMsec.GetMinutes(), 0, 0) - wxTimeSpan(hours)).GetMinutes();
+ long seconds = (wxTimeSpan(0, 0, tsMsec.GetSeconds(), 0) - wxTimeSpan(0, minutes)).GetSeconds().ToLong();
+ long milliseconds = (wxTimeSpan(0, 0, 0, tsMsec.GetMilliseconds()) - wxTimeSpan(0, 0, seconds)).GetMilliseconds().ToLong();
+
+ if (days > 0)
+ return wxString::Format("%d %s, %02d:%02d:%02ld hours", days, wxT("days"), hours, minutes, seconds);
+ else if (hours > 0)
+ return wxString::Format("%02d:%02d:%02ld hours", hours, minutes, seconds);
+ else if (msec >= 1000 * 60)
+ return wxString::Format("%02d:%02ld minutes", minutes, seconds);
+ else if (msec >= 1000)
+ return wxString::Format("%ld.%ld secs", seconds, milliseconds / 100);
+ else
+ return msec.ToString() + wxT(" msec");
+}
+
wxDateTime StrToDateTime(const wxString &value)
{
wxDateTime dt;
Re: [PATCH] Add ElapsedTimeToString to format execution time in a more readable manner (instead of showing everything as msec)
From
Ashesh Vashi
Date:
Hi John,
Can you please add comments for the below piece of code for explanation?-----
@@ -3088,13 +3090,22 @@ void frmQuery::OnTimer(wxTimerEvent &event)
}
// Increase the granularity for longer running queries
- if (elapsedQuery > 200 && timer.GetInterval() == 10 && timer.IsRunning())
+ if (timer.IsRunning())
{
- timer.Stop();
- timer.Start(100);
+ if (elapsedQuery > 200 && timer.GetInterval() < 100)
+ {
+ timer.Stop();
+ timer.Start(100);
+ }
+ else if (elapsedQuery > 60 * 1000 && timer.GetInterval() < 1000)
+ {
+ timer.Stop();
+ timer.Start(1000);
+ }
-----
And, please send patch as an attachment.
On Fri, Jun 12, 2015 at 1:50 AM, John Obaterspok <john.obaterspok@gmail.com> wrote:
Add ElapsedTimeToString to format execution time in a more readable manner (instead of showing everything as msec)Signed-off-by: John Obaterspok <john.obaterspok@gmail.com>diff --git a/pgadmin/dlg/dlgClasses.cpp b/pgadmin/dlg/dlgClasses.cppindex 9a3e473..e6fa488 100644--- a/pgadmin/dlg/dlgClasses.cpp+++ b/pgadmin/dlg/dlgClasses.cpp@@ -562,7 +562,7 @@ void ExecutionDialog::OnOK(wxCommandEvent &ev){if (txtMessages)txtMessages->AppendText(_("Total query runtime: ")- + (wxGetLocalTimeMillis() - startTime).ToString() + wxT(" ms."));+ + ElapsedTimeToString(wxGetLocalTimeMillis() - startTime));btnOK->SetLabel(_("Done"));btnCancel->Disable();diff --git a/pgadmin/frm/frmMain.cpp b/pgadmin/frm/frmMain.cppindex 8629dda..94528e8 100644--- a/pgadmin/frm/frmMain.cpp+++ b/pgadmin/frm/frmMain.cpp@@ -1352,9 +1352,7 @@ void frmMain::EndMsg(bool done){// Get the execution time & display itfloat timeval = stopwatch.Time();- wxString time;- time.Printf(_("%.2f secs"), (timeval / 1000));- statusBar->SetStatusText(time, 2);+ statusBar->SetStatusText(ElapsedTimeToString(timeval), 2);// Display the 'Done' messageif (done)@@ -1362,7 +1360,7 @@ void frmMain::EndMsg(bool done)elsestatusBar->SetStatusText(timermsg + _(" Failed."), 1);- wxLogStatus(wxT("%s (%s)"), timermsg.c_str(), time.c_str());+ wxLogStatus(wxT("%s (%s)"), timermsg.c_str(), ElapsedTimeToString(timeval).c_str());wxEndBusyCursor();}}diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cppindex 110bbc7..6198c83 100644--- a/pgadmin/frm/frmQuery.cpp+++ b/pgadmin/frm/frmQuery.cpp@@ -55,6 +55,7 @@#include "utils/sysLogger.h"#include "utils/sysSettings.h"#include "utils/utffile.h"+#include "utils/misc.h"#include "pgscript/pgsApplication.h"// Icons@@ -2711,7 +2712,7 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)msgHistory->AppendText(str);elapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);if (sqlResult->RunStatus() != PGRES_TUPLES_OK){@@ -2724,28 +2725,28 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)OID insertedOid = sqlResult->InsertedOid();if (insertedCount < 0){- showMessage(wxString::Format(_("Query returned successfully with no result in %s ms."),- elapsedQuery.ToString().c_str()), _("OK."));+ showMessage(wxString::Format(_("Query returned successfully with no result in %s."),+ ElapsedTimeToString(elapsedQuery).c_str()), _("OK."));}else if (insertedCount == 1){if (insertedOid){- showMessage(wxString::Format(_("Query returned successfully: one row with OID %ld inserted, %s ms execution time."),- (long)insertedOid, elapsedQuery.ToString().c_str()),+ showMessage(wxString::Format(_("Query returned successfully: one row with OID %ld inserted, %s execution time."),+ (long)insertedOid, ElapsedTimeToString(elapsedQuery).c_str()),wxString::Format(_("One row with OID %ld inserted."), (long)insertedOid));}else{- showMessage(wxString::Format(_("Query returned successfully: one row affected, %s ms execution time."),- elapsedQuery.ToString().c_str()),+ showMessage(wxString::Format(_("Query returned successfully: one row affected, %s execution time."),+ ElapsedTimeToString(elapsedQuery).c_str()),wxString::Format(_("One row affected.")));}}else{- showMessage(wxString::Format(_("Query returned successfully: %d rows affected, %s ms execution time."),- insertedCount, elapsedQuery.ToString().c_str()),+ showMessage(wxString::Format(_("Query returned successfully: %d rows affected, %s execution time."),+ insertedCount, ElapsedTimeToString(elapsedQuery).c_str()),wxString::Format(_("%d rows affected."), insertedCount));}}@@ -2865,9 +2866,9 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)sqlResult->DisplayData();- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);- str = _("Total query runtime: ") + elapsedQuery.ToString() + wxT(" ms.\n") ;+ str = _("Total query runtime: ") + ElapsedTimeToString(elapsedQuery) + "\n";msgResult->AppendText(str);msgHistory->AppendText(str);@@ -2952,9 +2953,10 @@ void frmQuery::OnScriptComplete(wxCommandEvent &ev)// Manage timerelapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ wxString fmtExecTime = ElapsedTimeToString(elapsedQuery);+ SetStatusText(fmtExecTime, STATUSPOS_SECS);SetStatusText(_("pgScript completed."), STATUSPOS_MSGS);- wxString str = _("Total pgScript runtime: ") + elapsedQuery.ToString() + wxT(" ms.\n\n");+ wxString str = _("Total pgScript runtime: ") + fmtExecTime + "\n\n";msgHistory->AppendText(str);// Check whether there was an error/exception@@ -3078,7 +3080,7 @@ void frmQuery::completeQuery(bool done, bool explain, bool verbose)void frmQuery::OnTimer(wxTimerEvent &event){elapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);wxString str = sqlResult->GetMessagesAndClear();if (!str.IsEmpty())@@ -3088,13 +3090,22 @@ void frmQuery::OnTimer(wxTimerEvent &event)}// Increase the granularity for longer running queries- if (elapsedQuery > 200 && timer.GetInterval() == 10 && timer.IsRunning())+ if (timer.IsRunning()){- timer.Stop();- timer.Start(100);+ if (elapsedQuery > 200 && timer.GetInterval() < 100)+ {+ timer.Stop();+ timer.Start(100);+ }+ else if (elapsedQuery > 60 * 1000 && timer.GetInterval() < 1000)+ {+ timer.Stop();+ timer.Start(1000);+ }}}+// Adjust sizes of GQB components, Located here because need to// avoid some issues when implementing inside controller/view Classesvoid frmQuery::adjustGQBSizes()diff --git a/pgadmin/include/utils/misc.h b/pgadmin/include/utils/misc.hindex abef297..07713ae 100644--- a/pgadmin/include/utils/misc.h+++ b/pgadmin/include/utils/misc.h@@ -117,6 +117,7 @@ wxString NumToStr(double value);wxString NumToStr(OID value);wxString NumToStr(wxLongLong value);wxString DateToStr(const wxDateTime &datetime);+wxString ElapsedTimeToString(wxLongLong msec);// Quotingdiff --git a/pgadmin/utils/misc.cpp b/pgadmin/utils/misc.cppindex b7d8afe..9a134fb 100644--- a/pgadmin/utils/misc.cpp+++ b/pgadmin/utils/misc.cpp@@ -219,6 +219,28 @@ wxString DateToStr(const wxDateTime &datetime)}+wxString ElapsedTimeToString(wxLongLong msec)+{+ wxTimeSpan tsMsec(0, 0, 0, msec);++ int days = tsMsec.GetDays();+ int hours = (wxTimeSpan(tsMsec.GetHours(), 0, 0, 0) - wxTimeSpan(days * 24)).GetHours();+ int minutes = (wxTimeSpan(0, tsMsec.GetMinutes(), 0, 0) - wxTimeSpan(hours)).GetMinutes();+ long seconds = (wxTimeSpan(0, 0, tsMsec.GetSeconds(), 0) - wxTimeSpan(0, minutes)).GetSeconds().ToLong();+ long milliseconds = (wxTimeSpan(0, 0, 0, tsMsec.GetMilliseconds()) - wxTimeSpan(0, 0, seconds)).GetMilliseconds().ToLong();++ if (days > 0)+ return wxString::Format("%d %s, %02d:%02d:%02ld hours", days, wxT("days"), hours, minutes, seconds);+ else if (hours > 0)+ return wxString::Format("%02d:%02d:%02ld hours", hours, minutes, seconds);+ else if (msec >= 1000 * 60)+ return wxString::Format("%02d:%02ld minutes", minutes, seconds);+ else if (msec >= 1000)+ return wxString::Format("%ld.%ld secs", seconds, milliseconds / 100);+ else+ return msec.ToString() + wxT(" msec");+}+wxDateTime StrToDateTime(const wxString &value){wxDateTime dt;
Re: [PATCH] Add ElapsedTimeToString to format execution time in a more readable manner (instead of showing everything as msec)
From
John Obaterspok
Date:
Hi,
Attached is an updated patch.
-- john
2015-06-12 6:50 GMT+02:00 Ashesh Vashi <ashesh.vashi@enterprisedb.com>:
Hi John,Can you please add comments for the below piece of code for explanation?
-----@@ -3088,13 +3090,22 @@ void frmQuery::OnTimer(wxTimerEvent &event)}// Increase the granularity for longer running queries- if (elapsedQuery > 200 && timer.GetInterval() == 10 && timer.IsRunning())+ if (timer.IsRunning()){- timer.Stop();- timer.Start(100);+ if (elapsedQuery > 200 && timer.GetInterval() < 100)+ {+ timer.Stop();+ timer.Start(100);+ }+ else if (elapsedQuery > 60 * 1000 && timer.GetInterval() < 1000)+ {+ timer.Stop();+ timer.Start(1000);+ }
-----And, please send patch as an attachment.On Fri, Jun 12, 2015 at 1:50 AM, John Obaterspok <john.obaterspok@gmail.com> wrote:Add ElapsedTimeToString to format execution time in a more readable manner (instead of showing everything as msec)Signed-off-by: John Obaterspok <john.obaterspok@gmail.com>diff --git a/pgadmin/dlg/dlgClasses.cpp b/pgadmin/dlg/dlgClasses.cppindex 9a3e473..e6fa488 100644--- a/pgadmin/dlg/dlgClasses.cpp+++ b/pgadmin/dlg/dlgClasses.cpp@@ -562,7 +562,7 @@ void ExecutionDialog::OnOK(wxCommandEvent &ev){if (txtMessages)txtMessages->AppendText(_("Total query runtime: ")- + (wxGetLocalTimeMillis() - startTime).ToString() + wxT(" ms."));+ + ElapsedTimeToString(wxGetLocalTimeMillis() - startTime));btnOK->SetLabel(_("Done"));btnCancel->Disable();diff --git a/pgadmin/frm/frmMain.cpp b/pgadmin/frm/frmMain.cppindex 8629dda..94528e8 100644--- a/pgadmin/frm/frmMain.cpp+++ b/pgadmin/frm/frmMain.cpp@@ -1352,9 +1352,7 @@ void frmMain::EndMsg(bool done){// Get the execution time & display itfloat timeval = stopwatch.Time();- wxString time;- time.Printf(_("%.2f secs"), (timeval / 1000));- statusBar->SetStatusText(time, 2);+ statusBar->SetStatusText(ElapsedTimeToString(timeval), 2);// Display the 'Done' messageif (done)@@ -1362,7 +1360,7 @@ void frmMain::EndMsg(bool done)elsestatusBar->SetStatusText(timermsg + _(" Failed."), 1);- wxLogStatus(wxT("%s (%s)"), timermsg.c_str(), time.c_str());+ wxLogStatus(wxT("%s (%s)"), timermsg.c_str(), ElapsedTimeToString(timeval).c_str());wxEndBusyCursor();}}diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cppindex 110bbc7..6198c83 100644--- a/pgadmin/frm/frmQuery.cpp+++ b/pgadmin/frm/frmQuery.cpp@@ -55,6 +55,7 @@#include "utils/sysLogger.h"#include "utils/sysSettings.h"#include "utils/utffile.h"+#include "utils/misc.h"#include "pgscript/pgsApplication.h"// Icons@@ -2711,7 +2712,7 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)msgHistory->AppendText(str);elapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);if (sqlResult->RunStatus() != PGRES_TUPLES_OK){@@ -2724,28 +2725,28 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)OID insertedOid = sqlResult->InsertedOid();if (insertedCount < 0){- showMessage(wxString::Format(_("Query returned successfully with no result in %s ms."),- elapsedQuery.ToString().c_str()), _("OK."));+ showMessage(wxString::Format(_("Query returned successfully with no result in %s."),+ ElapsedTimeToString(elapsedQuery).c_str()), _("OK."));}else if (insertedCount == 1){if (insertedOid){- showMessage(wxString::Format(_("Query returned successfully: one row with OID %ld inserted, %s ms execution time."),- (long)insertedOid, elapsedQuery.ToString().c_str()),+ showMessage(wxString::Format(_("Query returned successfully: one row with OID %ld inserted, %s execution time."),+ (long)insertedOid, ElapsedTimeToString(elapsedQuery).c_str()),wxString::Format(_("One row with OID %ld inserted."), (long)insertedOid));}else{- showMessage(wxString::Format(_("Query returned successfully: one row affected, %s ms execution time."),- elapsedQuery.ToString().c_str()),+ showMessage(wxString::Format(_("Query returned successfully: one row affected, %s execution time."),+ ElapsedTimeToString(elapsedQuery).c_str()),wxString::Format(_("One row affected.")));}}else{- showMessage(wxString::Format(_("Query returned successfully: %d rows affected, %s ms execution time."),- insertedCount, elapsedQuery.ToString().c_str()),+ showMessage(wxString::Format(_("Query returned successfully: %d rows affected, %s execution time."),+ insertedCount, ElapsedTimeToString(elapsedQuery).c_str()),wxString::Format(_("%d rows affected."), insertedCount));}}@@ -2865,9 +2866,9 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)sqlResult->DisplayData();- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);- str = _("Total query runtime: ") + elapsedQuery.ToString() + wxT(" ms.\n") ;+ str = _("Total query runtime: ") + ElapsedTimeToString(elapsedQuery) + "\n";msgResult->AppendText(str);msgHistory->AppendText(str);@@ -2952,9 +2953,10 @@ void frmQuery::OnScriptComplete(wxCommandEvent &ev)// Manage timerelapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ wxString fmtExecTime = ElapsedTimeToString(elapsedQuery);+ SetStatusText(fmtExecTime, STATUSPOS_SECS);SetStatusText(_("pgScript completed."), STATUSPOS_MSGS);- wxString str = _("Total pgScript runtime: ") + elapsedQuery.ToString() + wxT(" ms.\n\n");+ wxString str = _("Total pgScript runtime: ") + fmtExecTime + "\n\n";msgHistory->AppendText(str);// Check whether there was an error/exception@@ -3078,7 +3080,7 @@ void frmQuery::completeQuery(bool done, bool explain, bool verbose)void frmQuery::OnTimer(wxTimerEvent &event){elapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);wxString str = sqlResult->GetMessagesAndClear();if (!str.IsEmpty())@@ -3088,13 +3090,22 @@ void frmQuery::OnTimer(wxTimerEvent &event)}// Increase the granularity for longer running queries- if (elapsedQuery > 200 && timer.GetInterval() == 10 && timer.IsRunning())+ if (timer.IsRunning()){- timer.Stop();- timer.Start(100);+ if (elapsedQuery > 200 && timer.GetInterval() < 100)+ {+ timer.Stop();+ timer.Start(100);+ }+ else if (elapsedQuery > 60 * 1000 && timer.GetInterval() < 1000)+ {+ timer.Stop();+ timer.Start(1000);+ }}}+// Adjust sizes of GQB components, Located here because need to// avoid some issues when implementing inside controller/view Classesvoid frmQuery::adjustGQBSizes()diff --git a/pgadmin/include/utils/misc.h b/pgadmin/include/utils/misc.hindex abef297..07713ae 100644--- a/pgadmin/include/utils/misc.h+++ b/pgadmin/include/utils/misc.h@@ -117,6 +117,7 @@ wxString NumToStr(double value);wxString NumToStr(OID value);wxString NumToStr(wxLongLong value);wxString DateToStr(const wxDateTime &datetime);+wxString ElapsedTimeToString(wxLongLong msec);// Quotingdiff --git a/pgadmin/utils/misc.cpp b/pgadmin/utils/misc.cppindex b7d8afe..9a134fb 100644--- a/pgadmin/utils/misc.cpp+++ b/pgadmin/utils/misc.cpp@@ -219,6 +219,28 @@ wxString DateToStr(const wxDateTime &datetime)}+wxString ElapsedTimeToString(wxLongLong msec)+{+ wxTimeSpan tsMsec(0, 0, 0, msec);++ int days = tsMsec.GetDays();+ int hours = (wxTimeSpan(tsMsec.GetHours(), 0, 0, 0) - wxTimeSpan(days * 24)).GetHours();+ int minutes = (wxTimeSpan(0, tsMsec.GetMinutes(), 0, 0) - wxTimeSpan(hours)).GetMinutes();+ long seconds = (wxTimeSpan(0, 0, tsMsec.GetSeconds(), 0) - wxTimeSpan(0, minutes)).GetSeconds().ToLong();+ long milliseconds = (wxTimeSpan(0, 0, 0, tsMsec.GetMilliseconds()) - wxTimeSpan(0, 0, seconds)).GetMilliseconds().ToLong();++ if (days > 0)+ return wxString::Format("%d %s, %02d:%02d:%02ld hours", days, wxT("days"), hours, minutes, seconds);+ else if (hours > 0)+ return wxString::Format("%02d:%02d:%02ld hours", hours, minutes, seconds);+ else if (msec >= 1000 * 60)+ return wxString::Format("%02d:%02ld minutes", minutes, seconds);+ else if (msec >= 1000)+ return wxString::Format("%ld.%ld secs", seconds, milliseconds / 100);+ else+ return msec.ToString() + wxT(" msec");+}+wxDateTime StrToDateTime(const wxString &value){wxDateTime dt;
Attachment
Re: [PATCH] Add ElapsedTimeToString to format execution time in a more readable manner (instead of showing everything as msec)
From
John Obaterspok
Date:
Hi,
Was the patch to format execution time in a more readable manner okay? Never got any feedback from the updated version.
Regards,
John
2015-06-15 21:28 GMT+02:00 John Obaterspok <john.obaterspok@gmail.com>:
Hi,Attached is an updated patch.-- john2015-06-12 6:50 GMT+02:00 Ashesh Vashi <ashesh.vashi@enterprisedb.com>:Hi John,Can you please add comments for the below piece of code for explanation?
-----@@ -3088,13 +3090,22 @@ void frmQuery::OnTimer(wxTimerEvent &event)}// Increase the granularity for longer running queries- if (elapsedQuery > 200 && timer.GetInterval() == 10 && timer.IsRunning())+ if (timer.IsRunning()){- timer.Stop();- timer.Start(100);+ if (elapsedQuery > 200 && timer.GetInterval() < 100)+ {+ timer.Stop();+ timer.Start(100);+ }+ else if (elapsedQuery > 60 * 1000 && timer.GetInterval() < 1000)+ {+ timer.Stop();+ timer.Start(1000);+ }
-----And, please send patch as an attachment.On Fri, Jun 12, 2015 at 1:50 AM, John Obaterspok <john.obaterspok@gmail.com> wrote:Add ElapsedTimeToString to format execution time in a more readable manner (instead of showing everything as msec)Signed-off-by: John Obaterspok <john.obaterspok@gmail.com>diff --git a/pgadmin/dlg/dlgClasses.cpp b/pgadmin/dlg/dlgClasses.cppindex 9a3e473..e6fa488 100644--- a/pgadmin/dlg/dlgClasses.cpp+++ b/pgadmin/dlg/dlgClasses.cpp@@ -562,7 +562,7 @@ void ExecutionDialog::OnOK(wxCommandEvent &ev){if (txtMessages)txtMessages->AppendText(_("Total query runtime: ")- + (wxGetLocalTimeMillis() - startTime).ToString() + wxT(" ms."));+ + ElapsedTimeToString(wxGetLocalTimeMillis() - startTime));btnOK->SetLabel(_("Done"));btnCancel->Disable();diff --git a/pgadmin/frm/frmMain.cpp b/pgadmin/frm/frmMain.cppindex 8629dda..94528e8 100644--- a/pgadmin/frm/frmMain.cpp+++ b/pgadmin/frm/frmMain.cpp@@ -1352,9 +1352,7 @@ void frmMain::EndMsg(bool done){// Get the execution time & display itfloat timeval = stopwatch.Time();- wxString time;- time.Printf(_("%.2f secs"), (timeval / 1000));- statusBar->SetStatusText(time, 2);+ statusBar->SetStatusText(ElapsedTimeToString(timeval), 2);// Display the 'Done' messageif (done)@@ -1362,7 +1360,7 @@ void frmMain::EndMsg(bool done)elsestatusBar->SetStatusText(timermsg + _(" Failed."), 1);- wxLogStatus(wxT("%s (%s)"), timermsg.c_str(), time.c_str());+ wxLogStatus(wxT("%s (%s)"), timermsg.c_str(), ElapsedTimeToString(timeval).c_str());wxEndBusyCursor();}}diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cppindex 110bbc7..6198c83 100644--- a/pgadmin/frm/frmQuery.cpp+++ b/pgadmin/frm/frmQuery.cpp@@ -55,6 +55,7 @@#include "utils/sysLogger.h"#include "utils/sysSettings.h"#include "utils/utffile.h"+#include "utils/misc.h"#include "pgscript/pgsApplication.h"// Icons@@ -2711,7 +2712,7 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)msgHistory->AppendText(str);elapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);if (sqlResult->RunStatus() != PGRES_TUPLES_OK){@@ -2724,28 +2725,28 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)OID insertedOid = sqlResult->InsertedOid();if (insertedCount < 0){- showMessage(wxString::Format(_("Query returned successfully with no result in %s ms."),- elapsedQuery.ToString().c_str()), _("OK."));+ showMessage(wxString::Format(_("Query returned successfully with no result in %s."),+ ElapsedTimeToString(elapsedQuery).c_str()), _("OK."));}else if (insertedCount == 1){if (insertedOid){- showMessage(wxString::Format(_("Query returned successfully: one row with OID %ld inserted, %s ms execution time."),- (long)insertedOid, elapsedQuery.ToString().c_str()),+ showMessage(wxString::Format(_("Query returned successfully: one row with OID %ld inserted, %s execution time."),+ (long)insertedOid, ElapsedTimeToString(elapsedQuery).c_str()),wxString::Format(_("One row with OID %ld inserted."), (long)insertedOid));}else{- showMessage(wxString::Format(_("Query returned successfully: one row affected, %s ms execution time."),- elapsedQuery.ToString().c_str()),+ showMessage(wxString::Format(_("Query returned successfully: one row affected, %s execution time."),+ ElapsedTimeToString(elapsedQuery).c_str()),wxString::Format(_("One row affected.")));}}else{- showMessage(wxString::Format(_("Query returned successfully: %d rows affected, %s ms execution time."),- insertedCount, elapsedQuery.ToString().c_str()),+ showMessage(wxString::Format(_("Query returned successfully: %d rows affected, %s execution time."),+ insertedCount, ElapsedTimeToString(elapsedQuery).c_str()),wxString::Format(_("%d rows affected."), insertedCount));}}@@ -2865,9 +2866,9 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)sqlResult->DisplayData();- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);- str = _("Total query runtime: ") + elapsedQuery.ToString() + wxT(" ms.\n") ;+ str = _("Total query runtime: ") + ElapsedTimeToString(elapsedQuery) + "\n";msgResult->AppendText(str);msgHistory->AppendText(str);@@ -2952,9 +2953,10 @@ void frmQuery::OnScriptComplete(wxCommandEvent &ev)// Manage timerelapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ wxString fmtExecTime = ElapsedTimeToString(elapsedQuery);+ SetStatusText(fmtExecTime, STATUSPOS_SECS);SetStatusText(_("pgScript completed."), STATUSPOS_MSGS);- wxString str = _("Total pgScript runtime: ") + elapsedQuery.ToString() + wxT(" ms.\n\n");+ wxString str = _("Total pgScript runtime: ") + fmtExecTime + "\n\n";msgHistory->AppendText(str);// Check whether there was an error/exception@@ -3078,7 +3080,7 @@ void frmQuery::completeQuery(bool done, bool explain, bool verbose)void frmQuery::OnTimer(wxTimerEvent &event){elapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);wxString str = sqlResult->GetMessagesAndClear();if (!str.IsEmpty())@@ -3088,13 +3090,22 @@ void frmQuery::OnTimer(wxTimerEvent &event)}// Increase the granularity for longer running queries- if (elapsedQuery > 200 && timer.GetInterval() == 10 && timer.IsRunning())+ if (timer.IsRunning()){- timer.Stop();- timer.Start(100);+ if (elapsedQuery > 200 && timer.GetInterval() < 100)+ {+ timer.Stop();+ timer.Start(100);+ }+ else if (elapsedQuery > 60 * 1000 && timer.GetInterval() < 1000)+ {+ timer.Stop();+ timer.Start(1000);+ }}}+// Adjust sizes of GQB components, Located here because need to// avoid some issues when implementing inside controller/view Classesvoid frmQuery::adjustGQBSizes()diff --git a/pgadmin/include/utils/misc.h b/pgadmin/include/utils/misc.hindex abef297..07713ae 100644--- a/pgadmin/include/utils/misc.h+++ b/pgadmin/include/utils/misc.h@@ -117,6 +117,7 @@ wxString NumToStr(double value);wxString NumToStr(OID value);wxString NumToStr(wxLongLong value);wxString DateToStr(const wxDateTime &datetime);+wxString ElapsedTimeToString(wxLongLong msec);// Quotingdiff --git a/pgadmin/utils/misc.cpp b/pgadmin/utils/misc.cppindex b7d8afe..9a134fb 100644--- a/pgadmin/utils/misc.cpp+++ b/pgadmin/utils/misc.cpp@@ -219,6 +219,28 @@ wxString DateToStr(const wxDateTime &datetime)}+wxString ElapsedTimeToString(wxLongLong msec)+{+ wxTimeSpan tsMsec(0, 0, 0, msec);++ int days = tsMsec.GetDays();+ int hours = (wxTimeSpan(tsMsec.GetHours(), 0, 0, 0) - wxTimeSpan(days * 24)).GetHours();+ int minutes = (wxTimeSpan(0, tsMsec.GetMinutes(), 0, 0) - wxTimeSpan(hours)).GetMinutes();+ long seconds = (wxTimeSpan(0, 0, tsMsec.GetSeconds(), 0) - wxTimeSpan(0, minutes)).GetSeconds().ToLong();+ long milliseconds = (wxTimeSpan(0, 0, 0, tsMsec.GetMilliseconds()) - wxTimeSpan(0, 0, seconds)).GetMilliseconds().ToLong();++ if (days > 0)+ return wxString::Format("%d %s, %02d:%02d:%02ld hours", days, wxT("days"), hours, minutes, seconds);+ else if (hours > 0)+ return wxString::Format("%02d:%02d:%02ld hours", hours, minutes, seconds);+ else if (msec >= 1000 * 60)+ return wxString::Format("%02d:%02ld minutes", minutes, seconds);+ else if (msec >= 1000)+ return wxString::Format("%ld.%ld secs", seconds, milliseconds / 100);+ else+ return msec.ToString() + wxT(" msec");+}+wxDateTime StrToDateTime(const wxString &value){wxDateTime dt;
Re: [PATCH] Add ElapsedTimeToString to format execution time in a more readable manner (instead of showing everything as msec)
From
Ashesh Vashi
Date:
Hi John,
These lines should be part of this patch.@@ -2522,7 +2523,7 @@ bool frmQuery::isBeginNotRequired(wxString query)
/*
* Check word length (since "beginx" is not "begin").
*/
- while(wxIsalpha(query.GetChar(wordlen)))
+ while(wordlen < query.Length() && wxIsalpha(query.GetChar(wordlen)))
wordlen++;
/*
On Mon, Sep 14, 2015 at 1:16 AM, John Obaterspok <john.obaterspok@gmail.com> wrote:
Hi,Was the patch to format execution time in a more readable manner okay? Never got any feedback from the updated version.Regards,John2015-06-15 21:28 GMT+02:00 John Obaterspok <john.obaterspok@gmail.com>:Hi,Attached is an updated patch.-- john2015-06-12 6:50 GMT+02:00 Ashesh Vashi <ashesh.vashi@enterprisedb.com>:Hi John,Can you please add comments for the below piece of code for explanation?
-----@@ -3088,13 +3090,22 @@ void frmQuery::OnTimer(wxTimerEvent &event)}// Increase the granularity for longer running queries- if (elapsedQuery > 200 && timer.GetInterval() == 10 && timer.IsRunning())+ if (timer.IsRunning()){- timer.Stop();- timer.Start(100);+ if (elapsedQuery > 200 && timer.GetInterval() < 100)+ {+ timer.Stop();+ timer.Start(100);+ }+ else if (elapsedQuery > 60 * 1000 && timer.GetInterval() < 1000)+ {+ timer.Stop();+ timer.Start(1000);+ }
-----And, please send patch as an attachment.On Fri, Jun 12, 2015 at 1:50 AM, John Obaterspok <john.obaterspok@gmail.com> wrote:Add ElapsedTimeToString to format execution time in a more readable manner (instead of showing everything as msec)Signed-off-by: John Obaterspok <john.obaterspok@gmail.com>diff --git a/pgadmin/dlg/dlgClasses.cpp b/pgadmin/dlg/dlgClasses.cppindex 9a3e473..e6fa488 100644--- a/pgadmin/dlg/dlgClasses.cpp+++ b/pgadmin/dlg/dlgClasses.cpp@@ -562,7 +562,7 @@ void ExecutionDialog::OnOK(wxCommandEvent &ev){if (txtMessages)txtMessages->AppendText(_("Total query runtime: ")- + (wxGetLocalTimeMillis() - startTime).ToString() + wxT(" ms."));+ + ElapsedTimeToString(wxGetLocalTimeMillis() - startTime));btnOK->SetLabel(_("Done"));btnCancel->Disable();diff --git a/pgadmin/frm/frmMain.cpp b/pgadmin/frm/frmMain.cppindex 8629dda..94528e8 100644--- a/pgadmin/frm/frmMain.cpp+++ b/pgadmin/frm/frmMain.cpp@@ -1352,9 +1352,7 @@ void frmMain::EndMsg(bool done){// Get the execution time & display itfloat timeval = stopwatch.Time();- wxString time;- time.Printf(_("%.2f secs"), (timeval / 1000));- statusBar->SetStatusText(time, 2);+ statusBar->SetStatusText(ElapsedTimeToString(timeval), 2);// Display the 'Done' messageif (done)@@ -1362,7 +1360,7 @@ void frmMain::EndMsg(bool done)elsestatusBar->SetStatusText(timermsg + _(" Failed."), 1);- wxLogStatus(wxT("%s (%s)"), timermsg.c_str(), time.c_str());+ wxLogStatus(wxT("%s (%s)"), timermsg.c_str(), ElapsedTimeToString(timeval).c_str());wxEndBusyCursor();}}diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cppindex 110bbc7..6198c83 100644--- a/pgadmin/frm/frmQuery.cpp+++ b/pgadmin/frm/frmQuery.cpp@@ -55,6 +55,7 @@#include "utils/sysLogger.h"#include "utils/sysSettings.h"#include "utils/utffile.h"+#include "utils/misc.h"#include "pgscript/pgsApplication.h"// Icons@@ -2711,7 +2712,7 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)msgHistory->AppendText(str);elapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);if (sqlResult->RunStatus() != PGRES_TUPLES_OK){@@ -2724,28 +2725,28 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)OID insertedOid = sqlResult->InsertedOid();if (insertedCount < 0){- showMessage(wxString::Format(_("Query returned successfully with no result in %s ms."),- elapsedQuery.ToString().c_str()), _("OK."));+ showMessage(wxString::Format(_("Query returned successfully with no result in %s."),+ ElapsedTimeToString(elapsedQuery).c_str()), _("OK."));}else if (insertedCount == 1){if (insertedOid){- showMessage(wxString::Format(_("Query returned successfully: one row with OID %ld inserted, %s ms execution time."),- (long)insertedOid, elapsedQuery.ToString().c_str()),+ showMessage(wxString::Format(_("Query returned successfully: one row with OID %ld inserted, %s execution time."),+ (long)insertedOid, ElapsedTimeToString(elapsedQuery).c_str()),wxString::Format(_("One row with OID %ld inserted."), (long)insertedOid));}else{- showMessage(wxString::Format(_("Query returned successfully: one row affected, %s ms execution time."),- elapsedQuery.ToString().c_str()),+ showMessage(wxString::Format(_("Query returned successfully: one row affected, %s execution time."),+ ElapsedTimeToString(elapsedQuery).c_str()),wxString::Format(_("One row affected.")));}}else{- showMessage(wxString::Format(_("Query returned successfully: %d rows affected, %s ms execution time."),- insertedCount, elapsedQuery.ToString().c_str()),+ showMessage(wxString::Format(_("Query returned successfully: %d rows affected, %s execution time."),+ insertedCount, ElapsedTimeToString(elapsedQuery).c_str()),wxString::Format(_("%d rows affected."), insertedCount));}}@@ -2865,9 +2866,9 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent &ev)sqlResult->DisplayData();- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);- str = _("Total query runtime: ") + elapsedQuery.ToString() + wxT(" ms.\n") ;+ str = _("Total query runtime: ") + ElapsedTimeToString(elapsedQuery) + "\n";msgResult->AppendText(str);msgHistory->AppendText(str);@@ -2952,9 +2953,10 @@ void frmQuery::OnScriptComplete(wxCommandEvent &ev)// Manage timerelapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ wxString fmtExecTime = ElapsedTimeToString(elapsedQuery);+ SetStatusText(fmtExecTime, STATUSPOS_SECS);SetStatusText(_("pgScript completed."), STATUSPOS_MSGS);- wxString str = _("Total pgScript runtime: ") + elapsedQuery.ToString() + wxT(" ms.\n\n");+ wxString str = _("Total pgScript runtime: ") + fmtExecTime + "\n\n";msgHistory->AppendText(str);// Check whether there was an error/exception@@ -3078,7 +3080,7 @@ void frmQuery::completeQuery(bool done, bool explain, bool verbose)void frmQuery::OnTimer(wxTimerEvent &event){elapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;- SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);+ SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);wxString str = sqlResult->GetMessagesAndClear();if (!str.IsEmpty())@@ -3088,13 +3090,22 @@ void frmQuery::OnTimer(wxTimerEvent &event)}// Increase the granularity for longer running queries- if (elapsedQuery > 200 && timer.GetInterval() == 10 && timer.IsRunning())+ if (timer.IsRunning()){- timer.Stop();- timer.Start(100);+ if (elapsedQuery > 200 && timer.GetInterval() < 100)+ {+ timer.Stop();+ timer.Start(100);+ }+ else if (elapsedQuery > 60 * 1000 && timer.GetInterval() < 1000)+ {+ timer.Stop();+ timer.Start(1000);+ }}}+// Adjust sizes of GQB components, Located here because need to// avoid some issues when implementing inside controller/view Classesvoid frmQuery::adjustGQBSizes()diff --git a/pgadmin/include/utils/misc.h b/pgadmin/include/utils/misc.hindex abef297..07713ae 100644--- a/pgadmin/include/utils/misc.h+++ b/pgadmin/include/utils/misc.h@@ -117,6 +117,7 @@ wxString NumToStr(double value);wxString NumToStr(OID value);wxString NumToStr(wxLongLong value);wxString DateToStr(const wxDateTime &datetime);+wxString ElapsedTimeToString(wxLongLong msec);// Quotingdiff --git a/pgadmin/utils/misc.cpp b/pgadmin/utils/misc.cppindex b7d8afe..9a134fb 100644--- a/pgadmin/utils/misc.cpp+++ b/pgadmin/utils/misc.cpp@@ -219,6 +219,28 @@ wxString DateToStr(const wxDateTime &datetime)}+wxString ElapsedTimeToString(wxLongLong msec)+{+ wxTimeSpan tsMsec(0, 0, 0, msec);++ int days = tsMsec.GetDays();+ int hours = (wxTimeSpan(tsMsec.GetHours(), 0, 0, 0) - wxTimeSpan(days * 24)).GetHours();+ int minutes = (wxTimeSpan(0, tsMsec.GetMinutes(), 0, 0) - wxTimeSpan(hours)).GetMinutes();+ long seconds = (wxTimeSpan(0, 0, tsMsec.GetSeconds(), 0) - wxTimeSpan(0, minutes)).GetSeconds().ToLong();+ long milliseconds = (wxTimeSpan(0, 0, 0, tsMsec.GetMilliseconds()) - wxTimeSpan(0, 0, seconds)).GetMilliseconds().ToLong();++ if (days > 0)+ return wxString::Format("%d %s, %02d:%02d:%02ld hours", days, wxT("days"), hours, minutes, seconds);+ else if (hours > 0)+ return wxString::Format("%02d:%02d:%02ld hours", hours, minutes, seconds);+ else if (msec >= 1000 * 60)+ return wxString::Format("%02d:%02ld minutes", minutes, seconds);+ else if (msec >= 1000)+ return wxString::Format("%ld.%ld secs", seconds, milliseconds / 100);+ else+ return msec.ToString() + wxT(" msec");+}+wxDateTime StrToDateTime(const wxString &value){wxDateTime dt;