@@ -116,13 +116,13 @@ end
116
116
-- profiling call
117
117
function profiler :_profiling_call (funcinfo )
118
118
local report = self :_func_report (funcinfo )
119
- report .calltime = os.clock ()
119
+ report .calltime = os .mclock ()
120
120
report .callcount = report .callcount + 1
121
121
end
122
122
123
123
-- profiling return
124
124
function profiler :_profiling_return (funcinfo )
125
- local stoptime = os.clock ()
125
+ local stoptime = os .mclock ()
126
126
local report = self :_func_report (funcinfo )
127
127
if report .calltime and report .calltime > 0 then
128
128
report .totaltime = report .totaltime + (stoptime - report .calltime )
@@ -160,7 +160,7 @@ function profiler:start()
160
160
elseif self :is_perf (" call" ) then
161
161
self ._REPORTS = self ._REPORTS or {}
162
162
self ._REPORTS_BY_KEY = self ._REPORTS_BY_KEY or {}
163
- self ._STARTIME = self ._STARTIME or os.clock ()
163
+ self ._STARTIME = self ._STARTIME or os .mclock ()
164
164
debug.sethook (profiler ._profiling_handler , ' cr' , 0 )
165
165
end
166
166
end
@@ -170,7 +170,7 @@ function profiler:stop()
170
170
if self :is_trace () then
171
171
debug.sethook ()
172
172
elseif self :is_perf (" call" ) then
173
- self ._STOPTIME = os.clock ()
173
+ self ._STOPTIME = os .mclock ()
174
174
debug.sethook ()
175
175
176
176
-- calculate the total time
@@ -190,7 +190,7 @@ function profiler:stop()
190
190
if percent < 1 then
191
191
break
192
192
end
193
- local report_line = string.format (" %6.3f, %6.2f%%, %7d, %s" , report .totaltime , percent , report .callcount , self :_func_title (report .funcinfo ))
193
+ local report_line = string.format (" %6.3f, %6.2f%%, %7d, %s" , report .totaltime / 1000.0 , percent , report .callcount , self :_func_title (report .funcinfo ))
194
194
report_lines = report_lines .. report_line .. " \n "
195
195
utils .print (report_line )
196
196
end
@@ -214,7 +214,7 @@ function profiler:stop()
214
214
local report_lines = " "
215
215
while h :length () > 0 do
216
216
local report = h :pop ()
217
- local report_line = string.format (" %6.3f, %7d, %s" , report .totaltime , report .callcount , self :_tag_title (report .name , report .argv ))
217
+ local report_line = string.format (" %6.3f, %7d, %s" , report .totaltime / 1000.0 , report .callcount , self :_tag_title (report .name , report .argv ))
218
218
report_lines = report_lines .. report_line .. " \n "
219
219
count = count + 1
220
220
end
@@ -241,7 +241,7 @@ function profiler:enter(name, ...)
241
241
if is_perf_tag then
242
242
local argv = table.pack (... )
243
243
local report = self :_tag_report (name , argv )
244
- report .calltime = os.clock ()
244
+ report .calltime = os .mclock ()
245
245
report .callcount = report .callcount + 1
246
246
end
247
247
end
@@ -254,7 +254,7 @@ function profiler:leave(name, ...)
254
254
self ._IS_PERF_TAG = is_perf_tag
255
255
end
256
256
if is_perf_tag then
257
- local stoptime = os.clock ()
257
+ local stoptime = os .mclock ()
258
258
local argv = table.pack (... )
259
259
local report = self :_tag_report (name , argv )
260
260
if report .calltime and report .calltime > 0 then
0 commit comments