非常感谢帮助确定我如何计算Tandem(不间断)流程自创建以来所经过的时间。
例如: - 当我执行状态$ proc,DETAIL时,我可以获得进程创建时间,并在“进程创建时间”中获得文本时间 - 我想准确计算自创建流程以来的时间
我最初的想法是通过#TIMESTAMP(或#JULIANTIMESTAMP)获取当前时间,然后将文本处理创建时间转换为上述三字或四字格式之一,然后进行子选择以找到差异。之后,我会将该差异转换回文本以获得实际时间。
我在准确计算时遇到了挑战...... 感谢任何指导!
谢谢!
答案 0 :(得分:0)
我认为你有正确的想法,似乎没有一个简洁的方法(在TACL中)来获得进程创建时间,所以你必须处理status命令输出。这不会将变量作为OUTV参数,因此您可以使用文件,并在那里进行一些处理,而不是在TACL中。
我将两个时间戳都转换为#CONTIME给出的空格分隔列表,然后将它们转换为Julian时间戳(见下文)。
在(例如)C中可能更容易做到,您可以在其中调用PROCESS_GETINFOLIST_直接获取创建时间戳。在OSS shell中可能更容易,因为它可以更好地处理那里的时间戳。
?TACL ROUTINE
#FRAME
#PUSH tempfile
#SET tempfile XXTEMPXX
[#DEF MakeTimeList ROUTINE |BODY|
#FRAME
#PUSH month day year time hour min sec centi milli
SINK [#ARGUMENT/VALUE month/WORD]
SINK [#ARGUMENT/VALUE day/WORD]
SINK [#ARGUMENT COMMA]
SINK [#ARGUMENT/VALUE year/NUMBER]
SINK [#ARGUMENT/VALUE hour/NUMBER]
SINK [#ARGUMENT/VALUE min/NUMBER]
SINK [#ARGUMENT/VALUE sec/NUMBER]
SINK [#ARGUMENT/VALUE centi/NUMBER]
[#CASE [month]
|January| #SET month 1
|February| #SET month 2
|March| #SET month 3
|April| #SET month 4
|May| #SET month 5
|June| #SET month 6
|July| #SET month 7
|August| #SET month 8
|September| #SET month 9
|October| #SET month 10
|November| #SET month 11
|December| #SET month 12
]
#SET milli [#CHARGET centi 4 TO 6]
#SET centi [#CHARGET centi 1 TO 3]
#RESULT [year] [month] [day] [hour] [min] [sec] [centi] [milli]
#UNFRAME
]
#PUSH start now lines line pos process
SINK [#ARGUMENT/VALUE process/ PROCESSNAME]
[#IF NOT [#PROCESSEXISTS [process]] |THEN|
#OUTPUT [process] does not exist
]
status/out [tempfile]/[process],detail
edit [tempfile];cqab/:/ /a;cqab/./ /a;exit
filetovar [tempfile] lines
SINK [#PURGE [tempfile]]
#SET pos [#LINEFIND lines 1 Process Creation Time]
[#IF pos > 1 |THEN|
#SET line [#LINEGET lines [pos]]
#SET start [#CHARGET line 23 TO [#CHARCOUNT line]]
#SET start [MakeTimeList [start]]
#SETMANY start, [#COMPUTETIMESTAMP [start] ]
#SETMANY now, [#COMPUTETIMESTAMP [#CONTIME [#TIMESTAMP]] 0]
#OUTPUT [#COMPUTE ([now] - [start])/1000000] seconds have elapsed
]
#UNFRAME
答案 1 :(得分:0)
TACL具有非常好的处理时间内置函数,请尝试以下操作:
?tacl routine
#frame
[#push
inProcess processCreateTime timeRightNow
timeDifference aMicroSecond aMilliSecond
pctY pctM pctD pctH pctMI pctS pctMIL pctMIC
trnY trnM trnD trnH trnMI trnS trnMIL trnMIC
]
#setmany aMicroSecond aMilliSecond , 1000000 1000
#if [#argument/value inProcess/processid]
#set processCreateTime [#processinfo/processcreationtime/[inProcess]]
[#setmany _ pctY pctM pctD pctH pctMI pctS pctMIL pctMIC , [#interprettimestamp [processCreateTime]]]
#set timeRightNow [#juliantimestamp]
[#setmany _ trnY trnM trnD trnH trnMI trnS trnMIL trnMIC , [#interprettimestamp [timeRightNow]]]
#output Process [#shiftstring [inProcess]] create vs now times
#set timeDifference [#compute [timeRightNow] - [processCreateTime]]
#output Created: [pctY]-[pctM]-[pctD] [pctH]:[pctMI]:[pctS]
#output Time Now: [trnY]-[trnM]-[trnD] [trnH]:[trnMI]:[trnS]
#output Differences:
#output in micros: [timeDifference]
#output in mills: [#compute [timeDifference] / [aMilliSecond]]
#output in seconds: [#compute [timeDifference] / [aMicroSecond]]
#unframe