cli: add time command
This commit is contained in:
@@ -30,6 +30,7 @@ from cmd import Cmd
|
|||||||
from os import isatty
|
from os import isatty
|
||||||
from select import poll, POLLIN
|
from select import poll, POLLIN
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
from mininet.log import info, output, error
|
from mininet.log import info, output, error
|
||||||
from mininet.term import makeTerms
|
from mininet.term import makeTerms
|
||||||
@@ -278,6 +279,13 @@ class CLI( Cmd ):
|
|||||||
output( '*** ' + sw.name + ' ' + ('-' * 72) + '\n' )
|
output( '*** ' + sw.name + ' ' + ('-' * 72) + '\n' )
|
||||||
output( sw.dpctl( *args ) )
|
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 ):
|
def default( self, line ):
|
||||||
"""Called on an input line when the command prefix is not recognized.
|
"""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.
|
Overridden to run shell commands when a node is the first CLI argument.
|
||||||
|
|||||||
Reference in New Issue
Block a user