我需要测量邻居搜索算法的CPU时间。 (?im) # Case insensitive
^ # BOS
# Local part
(?= .{1,64} @ ) # 64 max chars
(?:
( # (1 start), Quoted
" [^"\\]*
(?: \\ . [^"\\]* )*
"
@
) # (1 end)
| # or,
( # (2 start), Non-quoted
(?:
(?: # comment
\( [^)]* \) # comment, or
| [^\W_] # [0-9a-z]
)
(?:
\. # dot
(?! \. ) # if not followed by dot
| # or,
[-!#\$%&'\*\+/=\?\^`\{\}\|~\w] # words or special chars
| # or,
\( [^)]* \) # comment
)*
)?
[^\W_] # [0-9a-z]
(?: \( [^)]* \) )? # optional comment here
@
) # (2 end)
)
# Domain part
(?= .{1,255} $ ) # 255 max chars
(?:
( # (3 start), IP
\[ # obviously, needs ip speced regex here
[^\[\]]+
\]
) # (3 end)
| # or,
( # (4 start), Others
(?: # Labels (63 max chars each)
(?= .{1,63} \. )
[^\W_] [-\w]* [^\W_]* # [0-9a-z] [-\w]* [0-9a-z]*
\.
)+
[^\W_] # [a-z0-9] [\-a-z0-9]{0,22} [a-z0-9]
(?: [^\W_] | - ){0,22}
[^\W_]
) # (4 end)
| # or,
( # (5 start), Localdomain
(?= .{1,63} $ )
[^\W_] [-\w]* # [0-9a-z] [-\w]*
) # (5 end)
)
$ # EOS
不适合,因为它很耗时。
我已经尝试过timeit
,但是它只返回时间。有人报告%%time
在Unix系统上工作。有什么方法可以计算Windows系统下的CPU时间?