mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Core: TIMING improvements, usecs (microseconds precision time), ide: Debugger now underlines main thread
git-svn-id: svn://ultimatepp.org/upp/trunk@12499 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
35681b23c8
commit
d7553a42bd
6 changed files with 36 additions and 22 deletions
|
|
@ -177,6 +177,7 @@
|
|||
#include <winuser.h>
|
||||
#include <Wincon.h>
|
||||
#include <float.h>
|
||||
#include <mmsystem.h>
|
||||
#define byte win32_byte_ // RpcNdr defines byte -> class with Upp::byte
|
||||
#define CY win32_CY_
|
||||
#include <objidl.h>
|
||||
|
|
@ -238,6 +239,7 @@ typedef int SOCKET;
|
|||
#include <complex>
|
||||
#include <type_traits>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
|
||||
// fix MSC8 beta problem....
|
||||
#ifdef COMPILER_MSC
|
||||
|
|
|
|||
|
|
@ -42,23 +42,9 @@ inline int tmGetTime() {
|
|||
}
|
||||
#endif
|
||||
|
||||
static TimingInspector& s_zero()
|
||||
{
|
||||
static TimingInspector *s_zero = NULL;
|
||||
static bool init = false;
|
||||
if(!init) {
|
||||
init = true;
|
||||
static TimingInspector s_zero_;
|
||||
s_zero = &s_zero_;
|
||||
int w = GetTickCount();
|
||||
while(GetTickCount() - w < 200)
|
||||
TimingInspector::Routine __(*s_zero);
|
||||
}
|
||||
return *s_zero;
|
||||
}
|
||||
static TimingInspector s_zero; // time of Start / End without actual body to measure
|
||||
|
||||
TimingInspector::TimingInspector(const char *_name) {
|
||||
s_zero(); //!! atexit
|
||||
name = _name ? _name : "";
|
||||
start_time = 0;
|
||||
all_count = call_count = max_nesting = nesting_depth = min_time = max_time = total_time = 0;
|
||||
|
|
@ -73,7 +59,7 @@ TimingInspector::TimingInspector(const char *_name) {
|
|||
|
||||
TimingInspector::~TimingInspector() {
|
||||
Mutex::Lock __(mutex);
|
||||
if(this == &s_zero()) return;
|
||||
if(this == &s_zero) return;
|
||||
StdLog() << Dump() << "\r\n";
|
||||
}
|
||||
|
||||
|
|
@ -109,8 +95,13 @@ String TimingInspector::Dump() {
|
|||
String s = Sprintf("TIMING %-15s: ", name);
|
||||
if(call_count == 0)
|
||||
return s + "No active hit";
|
||||
ONCELOCK {
|
||||
int w = GetTickCount();
|
||||
while(GetTickCount() - w < 200)
|
||||
TimingInspector::Routine __(s_zero);
|
||||
}
|
||||
double tm = max(0.0, double(total_time) / call_count / 1000 -
|
||||
double(s_zero().total_time) / s_zero().call_count / 1000);
|
||||
double(s_zero.total_time) / s_zero.call_count / 1000);
|
||||
return s
|
||||
+ timeFormat(tm * call_count)
|
||||
+ " - " + timeFormat(tm)
|
||||
|
|
|
|||
|
|
@ -187,7 +187,17 @@ dword GetTickCount() {
|
|||
}
|
||||
#endif
|
||||
|
||||
int msecs(int from) { return GetTickCount() - (dword)from; }
|
||||
int64 usecs(int64 prev)
|
||||
{
|
||||
auto p2 = std::chrono::high_resolution_clock::now();
|
||||
return std::chrono::duration_cast<std::chrono::microseconds>(p2.time_since_epoch()).count() - prev;
|
||||
}
|
||||
|
||||
int msecs(int prev)
|
||||
{
|
||||
auto p2 = std::chrono::high_resolution_clock::now();
|
||||
return (int)std::chrono::duration_cast<std::chrono::milliseconds>(p2.time_since_epoch()).count() - prev;
|
||||
}
|
||||
|
||||
void TimeStop::Reset()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ static const int _MAX_PATH = PATH_MAX;
|
|||
dword GetTickCount();
|
||||
#endif
|
||||
|
||||
int msecs(int from = 0);
|
||||
int64 usecs(int64 prev = 0);
|
||||
int msecs(int prev = 0);
|
||||
|
||||
class TimeStop : Moveable<TimeStop> {
|
||||
dword starttime;
|
||||
|
|
|
|||
|
|
@ -60,8 +60,10 @@ void Pdb::Sync()
|
|||
for(int i = 0; i < threads.GetCount(); i++) {
|
||||
int thid = threads.GetKey(i);
|
||||
AttrText x(Format("0x%x", thid));
|
||||
if(thid == mainThreadId)
|
||||
x.Underline();
|
||||
if(thid == debug_threadid)
|
||||
x.font = StdFont().Bold();
|
||||
x.Bold();
|
||||
threadlist.Add(thid, x);
|
||||
}
|
||||
threadlist <<= (int)debug_threadid;
|
||||
|
|
|
|||
|
|
@ -287,6 +287,7 @@ String Gdb::ObtainThreadsInfo()
|
|||
String output = FastCmd("info threads");
|
||||
StringStream ss(output);
|
||||
int active_thread = -1;
|
||||
bool main = true;
|
||||
while(!ss.IsEof()) {
|
||||
String s = ss.GetLine();
|
||||
CParser p(s);
|
||||
|
|
@ -294,9 +295,16 @@ String Gdb::ObtainThreadsInfo()
|
|||
bool active = p.Char('*');
|
||||
if(p.IsNumber()) {
|
||||
int id = p.ReadInt();
|
||||
threads.Add(id, String().Cat() << "Thread " << id);
|
||||
if(active)
|
||||
AttrText text = String() << "Thread " << id;
|
||||
if(active) {
|
||||
active_thread = id;
|
||||
text.Bold();
|
||||
}
|
||||
if(main) {
|
||||
text.Underline();
|
||||
main = false;
|
||||
}
|
||||
threads.Add(id, text);
|
||||
}
|
||||
threads.GoBegin();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue