0

非常感谢帮助确定我如何计算自创建以来串联(不间断)流程所经过的时间。

例如: - 我可以在执行 STATUS $proc, DETAIL 时获得流程创建时间,并在“流程创建时间”中获得文本时间 - 我想准确计算自流程创建以来的时间

我最初的想法是通过#TIMESTAMP(或#JULIANTIMESTAMP)获取当前时间,然后将文本过程创建时间转换为上述三或四字格式之一,然后减去以找出差异。之后,我会将差异转换回文本以获取实际时间。

我在让这个准确计算方面遇到了挑战......感谢任何指导!

谢谢!

4

2 回答 2

0

我认为您的想法是正确的,似乎没有一种简洁的方法(在 TACL 中)来获取进程创建时间,因此您必须处理状态命令输出。这不会将变量作为 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
于 2013-10-24T04:15:29.580 回答
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
于 2020-02-25T17:14:51.343 回答