From d05e6fa8bfe0bdea30e0dd807e40d12814bce91a Mon Sep 17 00:00:00 2001 From: cxl Date: Sat, 18 Apr 2020 14:15:07 +0000 Subject: [PATCH] .cosmetics git-svn-id: svn://ultimatepp.org/upp/trunk@14328 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Util.cpp | 10 +++++++--- uppsrc/Core/Util.h | 6 +++--- uppsrc/CtrlCore/LocalLoop.cpp | 7 +++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/uppsrc/Core/Util.cpp b/uppsrc/Core/Util.cpp index fb07508b5..62020e8cd 100644 --- a/uppsrc/Core/Util.cpp +++ b/uppsrc/Core/Util.cpp @@ -209,7 +209,7 @@ int msecs(int prev) void TimeStop::Reset() { - starttime = GetTickCount(); + starttime = usecs(); } TimeStop::TimeStop() @@ -219,8 +219,12 @@ TimeStop::TimeStop() String TimeStop::ToString() const { - dword time = Elapsed(); - return Format("%d.%03d", int(time / 1000), int(time % 1000)); + double time = Elapsed(); + if(time < 1e3) + return String() << time << " us"; + if(time < 1e6) + return String() << time / 1e3 << " ms"; + return String() << time / 1e6 << " s"; } int RegisterTypeNo__(const char *type) diff --git a/uppsrc/Core/Util.h b/uppsrc/Core/Util.h index f11c7a737..1abdd4ad1 100644 --- a/uppsrc/Core/Util.h +++ b/uppsrc/Core/Util.h @@ -13,11 +13,11 @@ int64 usecs(int64 prev = 0); int msecs(int prev = 0); class TimeStop : Moveable { - dword starttime; + double starttime; public: - dword Elapsed() const { return GetTickCount() - starttime; } - double Seconds() const { return (double)Elapsed() / 1000; } + double Elapsed() const { return usecs() - starttime; } + double Seconds() const { return (double)Elapsed() / 1000000; } String ToString() const; void Reset(); diff --git a/uppsrc/CtrlCore/LocalLoop.cpp b/uppsrc/CtrlCore/LocalLoop.cpp index 74bfeeccc..002fdf290 100644 --- a/uppsrc/CtrlCore/LocalLoop.cpp +++ b/uppsrc/CtrlCore/LocalLoop.cpp @@ -70,7 +70,10 @@ void RectTracker::DrawRect(Draw& w, Rect r) void RectTracker::Paint(Draw& w) { - w.DrawImage(0, 0, master_image); + { + TIMESTOP("DrawImage"); + w.DrawImage(0, 0, master_image); + } w.Clip(clip & GetMaster().GetSize()); Rect r = rect; if(ty < 0) @@ -150,7 +153,7 @@ void RectTracker::MouseMove(Point, dword) if (rect.right < rect.left) { Swap(rect.right, rect.left); rect.InflateHorz(1); - } + } } if(ty == ALIGN_NULL) { rect.bottom = min(org.bottom - op.y + p.y, maxrect.bottom);