cli: add time command

This commit is contained in:
Brandon Heller
2012-05-25 16:34:05 -07:00
parent 6c947bca07
commit f509ae282d
+8
View File
@@ -30,6 +30,7 @@ from cmd import Cmd
from os import isatty
from select import poll, POLLIN
import sys
import time
from mininet.log import info, output, error
from mininet.term import makeTerms
@@ -278,6 +279,13 @@ class CLI( Cmd ):
output( '*** ' + sw.name + ' ' + ('-' * 72) + '\n' )
output( sw.dpctl( *args ) )
def do_time( self, line ):
"Measure time taken for any command in Mininet."
start = time.time()
self.onecmd(line)
elapsed = time.time() - start
self.stdout.write("*** Elapsed time: %0.6f secs\n" % elapsed)
def default( self, line ):
"""Called on an input line when the command prefix is not recognized.
Overridden to run shell commands when a node is the first CLI argument.