This info is not in the PyDelphin docs, I don’t think, but rather in the ItsdbProfile wiki, since ACE returns [incr tsdb()] fields when the tsdbinfo
parameter is set to True
(the default).
For each parse (the response from interact()
), you can use one of the total
, tcpu
, or treal
values. There is also first
, which is the time to the first reading, but I wasn’t seeing that one coming out of ACE, so I don’t include it here. Here is an example:
>>> grammar = '~/delphin/erg-2018.dat'
>>> with ace.ACEParser(grammar) as erg:
... response = erg.interact("What's the time?")
... print("total:", response["total"])
... print("tcpu:", response["tcpu"])
... print("treal:", response["treal"])
...
total: 14
tcpu: 14
treal: 14
NOTE: parsed 1 / 1 sentences, avg 3699k, time 0.01443s
Those times are in milliseconds, and note that they are the same as the stderr time.
You can also get timestamps for the start and end of a run (if you care about total runtime for a profile instead of per-item runtimes), but only the start
time is available inside the with-statement. To get the end
time, you must do it outside the with-statement or after the ACE process is otherwise closed. E.g.:
>>> with ace.ACEParser(grammar) as erg:
... # as before...
>>> # now the ace process is closed
>>> start = erg.run_info['start']
>>> end = erg.run_info['end']
>>> print('total runtime:', end - start)
total runtime: 0:00:00.036237
Note that this timing is more than just the parsing time, so it presumably includes the startup and teardown overhead time.
The response object you get from parser.interact()
is not much more than a regular dictionary, so you can inspect its contents with response.keys()
, etc., to see if there are any other useful fields.