question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Timing comparison for show commands

See original GitHub issue

During this last time I’ve been doing some testing, making different kind of executions, in terms of delay_factor, max_loops, mixed together with send_config_set() and send_command().

My conclusion is three fold:

  1. delay_factor should be tuned to improve interaction with the network;
  2. if using config like commands, send_config_set() is better; if show-like commands, send_command() is better;
  3. if send_config_set(), better off use it with cmd_verify=True.

I’ve performed some tests and it is true that when dealing with only config-like commands, send_config_set(cmd_verify=True) is an absolute winner.

But, when dealing with show-like commands, the picture is somehow different, at least for me.

Let me show you some results:

26 routers;
delayFactor=1;
maxLoops=5000;
device=nokia_sros;
commands=60 different show commands;
netmiko=3.4.0

And these are the code I’m using:

inText = [showCmd1, showCmd2, .... , shwCmd60]
if runType == 'config':
	output = conn2rtr.send_config_set(config_commands=inText, 
                                            enter_config_mode=False, 
                                            cmd_verify=cmdVerify, 
                                            delay_factor=delayFactor, 
                                            max_loops=maxLoops)
elif runType == 'show':
	output = ''
	for cmd in inText:
		output = output + '\n' + cmd + '\n' + conn2rtr.send_command(cmd, 
                                                                             delay_factor=delayFactor, 
                                                                             max_loops=maxLoops)

The results:

| send_config_set() | | send_command() – | – | --|– Data | verify=no | verify=yes | verify=n/a Count - Router | 26 | 26 | 26 showCommands | 60 | 60 | 60 Min - rxLines | 440 | 440 | 444 Average - rxLines | 5,211.77 | 5,212.73 | 5,216.85 Max - rxLines | 14282 | 14283 | 14287 Min - time(s) | 6.74 | 12.37 | 56.71 Average - time(s) | 13.31 | 17.81 | 60.81 Max - time(s) | 23.16 | 28.74 | 71.29

so, as you can see, the better performance in my case is not obtained with send_command() but with send_config_set().

It’s just a test that I wanted to share with you. I’ve repeated the tests several times, and the numbers are consistent.

Is it may be because I’m concatenating the results when using send_command() while send_config_set() gives me the result directly in the output variable? What is it that I’m doing wrong? Because show comands should better off treated with send_command(), isn’t it?

Regards!

Lucas

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ktbyerscommented, Aug 6, 2021

Okay, your numbers seem reasonably (i.e. make sense to me given how Netmiko works).

With the obvious caveat that I expect send_config_set() to generally not work and to not behave correctly for most show command operations (i.e. most people would run into issues using it).

1reaction
laimarettocommented, Aug 3, 2021

@ktbyers , thanks for the reply. Just to make it clear, I fully understand that show commands should be used with send_command() while config commands with send_config_set(). This was just a test that called my attention because of the apparent delay when using shows + send_command() compared to shows + send_config_set().

So, bottom line, II’ll do as you suggest: 1) try the expect_string in the send_command() call; 2) Try the develop branch. I’ll let you know about the results. thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Time Command Execution with the time Command
Learn how to track how long a command takes to execute from the command-line using the time command.
Read more >
timeit — Measure execution time of small code snippets ...
This module provides a simple way to time small bits of Python code. It has both a Command-Line Interface as well as a...
Read more >
Search commands > stats, chart, and timechart - Splunk
Use the timechart command to create results tables and charts that are based on time.
Read more >
batch file - How do I measure execution time of a command on ...
PowerShell has a cmdlet for this called Measure-Command . ... -a specifies that timeit should display average of all timings for the specified...
Read more >
Time and Date - clock - Tcl/Tk
The clock command provides access to the time and date functions in Tcl. Depending ... for comparison purposes, or as an input to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found