[
  {
    "path": ".gitignore",
    "content": "UnixBench*\nbigfile\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2013  Mario Gutierrez <mario@mgutz.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# vpsbench\n\nBenchmark VPS performance. See [user submissions](https://github.com/mgutz/vpsbench/wiki/VPS-Hosts)\n\nA script to run simple and comprehensive benchmarks on CPU and IO performance.\n\n\nTested on:\n\n* Debian 6\n* Debian 7\n* Debian 8\n* Ubuntu 10.04 LTS\n* Ubuntu 12.04 LTS\n* Ubuntu 14.04 LTS\n\n\n## Usage\n\n    Usage: vpsbench [OPTION...]\n\n    -a Bench all\n    -d Bench downloads\n    -f Create 100M bigfile\n    -x Remove temporary files\n    -u Bench unixbench\n\nDebian pre-requisites\n\n    apt-get install time bzip2\n\n\nExample\n\n\n    $ bash <(wget --no-check-certificate -O - https://raw.github.com/mgutz/vpsbench/master/vpsbench)\n\n    CPU model:  Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz\n    Number of cores: 4\n    CPU frequency:  3417.879 MHz\n    Total amount of RAM: 3265 MB\n    Total amount of swap: 1021 MB\n    System uptime:   8:41,\n    I/O speed:  427 MB/s\n    Bzip 25MB: 4.66s\n    Download 100MB file: 1.64MB/s\n\n\n## License\n\nLicensed under [The MIT License](LICENSE)\n"
  },
  {
    "path": "vpsbench",
    "content": "#!/bin/bash\n\n#==============================================================================\n# Copyright (c) 2013 Mario Gutierrez <mario@mgutz.com>\n#\n# Licensed under The MIT License\n#==============================================================================\n\n\n# Quick benchmark, always run\nfunction bench_quick {\n    local test_file=vpsbench__$$\n    local tar_file=tarfile\n    local now=$(date +\"%m/%d/%Y\")\n\n    local cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo )\n    local cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )\n    local freq=$( awk -F: ' /cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo )\n    local tram=$( free -m | awk 'NR==2 {print $2}' )\n    local swap=$( free -m | awk 'NR==4 {print $2}' )\n    local up=$(uptime|awk '{ $1=$2=$(NF-6)=$(NF-5)=$(NF-4)=$(NF-3)=$(NF-2)=$(NF-1)=$NF=\"\"; print }')\n\n    echo -n \"Benching I/O ... \"\n    local io=$( ( dd if=/dev/zero of=$test_file bs=64k count=16k conv=fdatasync && rm -f $test_file ) 2>&1 | awk -F, '{io=$NF} END { print io}' )\n    echo OK\n\n    echo -n \"Benching CPU. Bzipping 25MB file ... \"\n    dd if=/dev/urandom of=$tar_file bs=1024 count=25000 >>/dev/null 2>&1\n    local tf=$( (/usr/bin/time -f \"%es\" tar cfj $tar_file.bz2 $tar_file) 2>&1 )\n    rm -f tarfile*\n    echo OK\n\n    echo -n \"Benching inbound network. Downloading 100MB file ... \"\n    local dl=$( _dl http://cachefly.cachefly.net/100mb.test )\n    echo OK\n\n    cat <<INFO\nShare at https://github.com/mgutz/vpsbench/wiki/VPS-Hosts\n\n\n_$now - VMPLAN - DATACENTER - OS - AUTHOR_\n\\`\\`\\`\nCPU model: $cname\nNumber of cores: $cores\nCPU frequency: $freq MHz\nTotal amount of RAM: $tram MB\nTotal amount of swap: $swap MB\nSystem uptime: $up\nI/O speed: $io\nBzip 25MB: $tf\nDownload 100MB file: $dl\n\\`\\`\\`\n\n\nINFO\n\n}\n\nfunction _dl {\n    wget -O /dev/null \"$1\" 2>&1 | awk '/\\/dev\\/null/ {speed=$3 $4} END {gsub(/\\(|\\)/,\"\",speed); print speed}'\n}\n\n\n# Bench a single download file.\nfunction bench_dl {\n    echo -n \"Downloading from $1 ... \"\n    _dl \"$2\"\n}\n\n\n# Bench downloads from various places in the world.\nfunction bench_downloads {\n    echo\n\n    bench_dl \"CacheFly\" \\\n        http://cachefly.cachefly.net/100mb.test\n\n    bench_dl \"Linode - Atlanta GA\" \\\n        http://atlanta1.linode.com/100MB-atlanta.bin\n\n    bench_dl \"Linode - Dallas TX\" \\\n        http://dallas1.linode.com/100MB-dallas.bin\n\n    bench_dl \"Linode - Tokyo JP\" \\\n        http://tokyo1.linode.com/100MB-tokyo.bin\n\n    bench_dl \"Linode - London UK\" \\\n        http://speedtest.london.linode.com/100MB-london.bin\n\n    bench_dl \"Leaseweb - Haarlem NL\" \\\n        http://mirror.leaseweb.com/speedtest/100mb.bin\n\n    bench_dl \"Softlayer - Singapore\" \\\n        http://speedtest.sng01.softlayer.com/downloads/test100.zip\n\n    bench_dl \"Softlayer - Seattle WA\" \\\n        http://speedtest.sea01.softlayer.com/downloads/test100.zip\n\n    bench_dl \"Softlayer - San Jose CA\" \\\n        http://speedtest.sjc01.softlayer.com/downloads/test100.zip\n\n    bench_dl \"Softlayer - Washington DC\" \\\n        http://speedtest.wdc01.softlayer.com/downloads/test100.zip\n}\n\n\n# Ensure unix bench is installed (must be root)\nfunction ensure_unixbench {\n    test -d UnixBench && return\n\n    apt-get install build-essential\n    #apt-get install build-essential libx11-dev libgl1-mesa-dev libxext-dev\n\n    local file_ver=UnixBench5.1.3\n    wget -N http://byte-unixbench.googlecode.com/files/$file_ver.tgz\n    tar xvfz $file_ver.tgz\n}\n\n\n# Perform comprehensive benchmark of cpu and disk\nfunction bench_unixbench {\n    ensure_unixbench\n\n    pushd UnixBench > /dev/null\n    # dont need graphics\n    ./Run index\n    popd > /dev/null\n}\n\n\n# Creates a 100MB file for download testing.\nfunction create_big_file {\n    echo -n Creating big file ...\n    dd if=/dev/urandom of=bigfile bs=1024 count=102400\n    echo OK\n}\n\n\n# Remove temporary files and directories used/created during benchmarking.\nfunction remove_temporary_files {\n    echo -n Removing temporary files ...\n    rm -f vpsbench__*\n    rm -f bigfile\n    rm -rf UnixBench*\n    rm -rf tarfile*\n    echo OK\n}\n\n\n# Display usage.\nfunction usage {\n    cat <<USAGE\nUsage: vpsbench [OPTION...]\n\n-a Bench all\n-d Bench downloads\n-f Create 100M bigfile\n-x Remove temporary files\n-u Bench unixbench\nUSAGE\n}\n\n\n# The main script.\nfunction main {\n    bench_quick\n\n    test $do_downloads && bench_downloads\n    test $do_unixbench && bench_unixbench\n}\n\n\n# Parse command line options\nwhile getopts :adfxu opt; do\n    case \"$opt\" in\n        a)\n            do_downloads=true\n            do_unixbench=true\n            ;;\n        d)\n            do_downloads=true\n            ;;\n        f)\n            create_big_file\n            exit\n            ;;\n        x)\n            remove_temporary_files\n            exit\n            ;;\n        u)\n            do_unixbench=true\n            ;;\n        ?)\n            usage\n            exit 2\n            ;;\n    esac\ndone\n\nmain\n\n"
  }
]