Last active
May 19, 2017 04:21
-
-
Save ianloic/ff0c1bb77d46ddcd7cc089bf3bb00837 to your computer and use it in GitHub Desktop.
Comparing scp and netcp, nuc ethernet and USB ethernet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
# gzip a user.bootfs to make a high-entropy test files | |
# make 10M, 1M, 100K, 10K test files | |
gzip -c < $FUCHSIA_BUILD_DIR/user.bootfs | dd of=test-file-10M bs=1M count=10 iflag=fullblock | |
dd if=test-file-10M of=test-file-1M bs=1M count=1 | |
dd if=test-file-10M of=test-file-100K bs=10K count=10 | |
dd if=test-file-10M of=test-file-10K bs=10K count=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% ./run-test.py coral-dizzy-hunk-raid trap-flask-rail-opera | |
Testing connection to: coral-dizzy-hunk-raid | |
10K scp time=0.088932s σ=0.003256 bw=0.87848 mbits/sec | |
10K netcp time=0.005193s σ=0.000433 bw=15.04541 mbits/sec | |
100K scp time=0.092399s σ=0.004741 bw=8.45516 mbits/sec | |
100K netcp time=0.020258s σ=0.000809 bw=38.56483 mbits/sec | |
1M scp time=0.118176s σ=0.004014 bw=67.69536 mbits/sec | |
1M netcp time=0.175755s σ=0.006862 bw=45.51802 mbits/sec | |
10M scp time=0.370956s σ=0.003750 bw=215.65925 mbits/sec | |
10M netcp time=1.706349s σ=0.027708 bw=46.88374 mbits/sec | |
Testing connection to: trap-flask-rail-opera | |
10K scp time=0.250800s σ=0.080003 bw=0.31150 mbits/sec | |
10K netcp time=0.014889s σ=0.000192 bw=5.24703 mbits/sec | |
100K scp time=0.542324s σ=0.406794 bw=1.44056 mbits/sec | |
100K netcp time=0.105147s σ=0.000264 bw=7.43006 mbits/sec | |
1M scp time=0.850867s σ=0.324480 bw=9.40218 mbits/sec | |
1M netcp time=1.029841s σ=0.000276 bw=7.76819 mbits/sec | |
10M scp time=5.446646s σ=1.036078 bw=14.68794 mbits/sec | |
10M netcp time=10.247216s σ=0.001430 bw=7.80700 mbits/sec | |
coral-dizzy-hunk-raid is an intel NUC | |
trap-flask-rail-opera is an acer with USB ethernet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: latin-1 | |
import numpy | |
import os | |
import subprocess | |
import sys | |
import time | |
NUM_SAMPLES = 10 | |
def time_command(cmdline): | |
start = time.time() | |
subprocess.call( | |
cmdline, stdout=open(os.devnull, 'w'), stderr=subprocess.STDOUT) | |
end = time.time() | |
return end - start | |
def time_command_samples(cmdline, num_samples): | |
return [time_command(cmdline) for i in range(num_samples)] | |
def megabits(size, time): | |
return size * 8 / time / 1024 / 1024 | |
class Host(object): | |
def __init__(self, name): | |
self.name = name | |
self.fuchsia_addr = subprocess.check_output(['netaddr', '--fuchsia', | |
name]).strip() | |
def scp_command(self, local_filename, remote_filename): | |
return [ | |
'scp', '-F', os.environ['FUCHSIA_BUILD_DIR'] + '/ssh-keys/ssh_config', | |
local_filename, '[' + self.fuchsia_addr + ']:' + remote_filename | |
] | |
def netcp_command(self, local_filename, remote_filename): | |
return ['netcp', local_filename, self.name + ':' + remote_filename] | |
if __name__ == '__main__': | |
for hostname in sys.argv[1:]: | |
host = Host(hostname) | |
print 'Testing connection to: ' + hostname | |
for test in ('10K', '100K', '1M', '10M'): | |
filename = 'test-file-' + test | |
filesize = os.stat(filename).st_size | |
commands = (('scp', host.scp_command(filename, '/tmp/net-test')), | |
('netcp', host.netcp_command(filename, '/tmp/net-test'))) | |
for name, command in commands: | |
samples = time_command_samples(command, NUM_SAMPLES) | |
print '%5s %5s time=%5fs σ=%5f bw=%3.5f mbits/sec' % ( | |
test, name, numpy.mean(samples), numpy.std(samples), | |
megabits(filesize, numpy.mean(samples))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment