# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0.  If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.

module profiler;

pattern start()
address CMDstartProfiler
comment "Start offline performance profiling";

pattern stop():void
address CMDstopProfiler
comment "Stop offline performance profiling";

command starttrace()
address CMDstartTrace
comment "Start collecting trace information";

command starttrace(path:str)
address CMDstartTracePath
comment "Start collecting trace information and keep around in 'path' directory";

command stoptrace():void
address CMDstopTrace
comment "Stop collecting trace information";

command stoptrace(path:str):void
address CMDstopTracePath
comment "Stop collecting trace information";

command setheartbeat(b:int):void
address CMDsetHeartbeat
comment "Set heart beat performance tracing";

pattern openstream(mode:int):void
address CMDopenProfilerStream
comment "Start profiling the events, sent to output stream";

command closestream():void
address CMDcloseProfilerStream
comment "Stop offline proviling";

command noop():void
address CMDnoopProfiler
comment "Fetch any pending performance events";

command getTrace(e:str):bat[:any_1]
address CMDgetTrace
comment "Get the trace details of a specific event";

command cleanup():void
address CMDcleanupTraces
comment "Remove the temporary tables for profiling";

command getDiskReads():lng
address CMDgetDiskReads
comment "Obtain the number of physical reads";
command getDiskWrites():lng
address CMDgetDiskWrites
comment "Obtain the number of physical reads";

command getUserTime():lng
address CMDgetUserTime
comment "Obtain the user timing information.";
command getSystemTime():lng
address CMDgetSystemTime
comment "Obtain the user timing information.";

command cpustats()(user:lng, nice:lng, sys:lng,idle:lng,iowait:lng)
address CMDcpustats
comment "Extract cpu statistics from the kernel";

command cpuload(user:lng, nice:lng, sys:lng,idle:lng,iowait:lng)(cycles:int,io:int)
address CMDcpuloadPercentage
comment "Calculate the average cpu load percentage and io waiting times";
