Example #1
0
def run_all_benchmarks(nx_settings, nx_devices):
    print 'Querying NiceHash for miner connection information...'
    stratums = nicehash.simplemultialgo_info(nx_settings)[1]

    # TODO manage miners more gracefully
    excavator = miners.excavator.Excavator(nx_settings, stratums)
    excavator.load()
    algorithms = excavator.algorithms

    nx_benchmarks = {d: {} for d in nx_devices}
    for device in sorted(nx_devices, key=str):
        if isinstance(device, devices.nvidia.NvidiaDevice):
            print '\nCUDA device %d: %s' % (device.cuda_index, device.name)

        for algorithm in algorithms:
            status_dot = [-1]

            def report_speeds(sample, secs_remaining):
                status_dot[0] = (status_dot[0] + 1) % 3
                status_line = ''.join(
                    ['.' if i == status_dot[0] else ' ' for i in range(3)])
                if secs_remaining < 0:
                    print('  %s %s %s (warming up, %s)\r' %
                          (algorithm.name, status_line,
                           utils.format_speeds(sample),
                           utils.format_time(-secs_remaining))),
                else:
                    print('  %s %s %s (sampling, %s)  \r' %
                          (algorithm.name, status_line,
                           utils.format_speeds(sample),
                           utils.format_time(secs_remaining))),
                sys.stdout.flush()

            try:
                average_speeds = utils.run_benchmark(
                    algorithm,
                    device,
                    BENCHMARK_WARMUP_SECS,
                    BENCHMARK_SECS,
                    sample_callback=report_speeds)
            except KeyboardInterrupt:
                print 'Benchmarking aborted (completed benchmarks saved).'
                break
            else:
                nx_benchmarks[device][algorithm.name] = average_speeds
                print '  %s: %s                      ' % (
                    algorithm.name, utils.format_speeds(average_speeds))

    excavator.unload()

    return nx_benchmarks
Example #2
0
def run_benchmark(device, algorithm):
    status_dot = [-1]
    def report_speeds(sample, secs_remaining):
        status_dot[0] = (status_dot[0] + 1) % 3
        status_line = ''.join(['.' if i == status_dot[0] else ' ' for i in range(3)])
        if secs_remaining < 0:
            print ('  %s %s %s (warming up, %s)\r' %
                   (algorithm.name, status_line, utils.format_speeds(sample),
                    utils.format_time(-secs_remaining))),
        else:
            print ('  %s %s %s (sampling, %s)  \r' %
                   (algorithm.name, status_line, utils.format_speeds(sample),
                    utils.format_time(secs_remaining))),
        sys.stdout.flush()
    speeds = utils.run_benchmark(algorithm, device,
                                 algorithm.warmup_secs, BENCHMARK_SECS,
                                 sample_callback=report_speeds)
    print '  %s: %s                      ' % (algorithm.name,
                                              utils.format_speeds(speeds))
    return speeds
Example #3
0
stratums = {
    'neoscrypt': 'neoscrypt.usa.nicehash.com:3341',
    'equihash': 'equihash.usa.nicehash.com:3357',
    'daggerhashimoto': 'daggerhashimoto.usa.nicehash.com:3353',
    'pascal': 'pascal.usa.nicehash.com:3358'
}

my_settings = settings.DEFAULT_SETTINGS
my_settings['nicehash']['wallet'] = '3Qe7nT9hBSVoXr8rM2TG6pq82AmLVKHy23'

exc = miners.excavator.Excavator(my_settings, stratums)
exc.load()

ns = [a for a in exc.algorithms if a.algorithms == ['neoscrypt']][0]
ns.set_devices([devices[0]])
sleep(10)
ns.set_devices([])

eq = [a for a in exc.algorithms if a.algorithms == ['equihash']][0]
logging.info('equihash benchmark = ' +
             str(utils.run_benchmark(eq, devices[0], 30, 60)))

dp = [
    a for a in exc.algorithms if a.algorithms == ['daggerhashimoto', 'pascal']
][0]
logging.info('daggerhash-pascal benchmark = ' +
             str(utils.run_benchmark(dp, devices[0], 30, 60)))

exc.unload()
Example #4
0
import time

from utils import run_benchmark

from query_count.models import Book

def benchmark():
    Book.objects.count()

run_benchmark(benchmark, trials=50)
Example #5
0
from django.core.urlresolvers import reverse

from utils import run_benchmark

def benchmark():
    reverse('url_resolve.views.basic')
    reverse('url_resolve.views.catchall')

run_benchmark(benchmark)
Example #6
0
objects1 = [object(), object(), object(), object(), object()]
objects2 = [object(), object(), object(), object(), object()]
object1 = object()
object2 = object()
object3 = None
num1 = 1
num2 = 2
boolean1 = True
SCRIPT_CONTENT_URL = '/some/prefix'
WEBSITE_DOMAIN = 'http://www.somedomain.com'
SHOW_ALT_HEADER = 'True'


def benchmark():
    context = {
        'objects1': objects1,
        'objects2': objects2,
        'object1': object1,
        'object2': object2,
        'object3': object3,
        'num1' : num1,
        'num2' : num2,
        'boolean1': boolean1,
        'SCRIPT_CONTENT_URL': SCRIPT_CONTENT_URL,
        'WEBSITE_DOMAIN': WEBSITE_DOMAIN,
        'SHOW_ALT_HEADER': SHOW_ALT_HEADER
    }
    render_to_response('permalink.html', context)

run_benchmark(benchmark, syncdb=False, trials=100)
Example #7
0
from form_is_valid.forms import BookForm
from utils import run_benchmark

def setup():
    global book_form
    book_form = BookForm({'title': 'a'})
    
def benchmark():
    global book_form
    book_form.is_valid()

run_benchmark(benchmark, setup=setup, trials=50)
Example #8
0
import itertools
from query_get_or_create.models import Book
from utils import run_benchmark

counter = itertools.count(1)

def benchmark():
    nextid = counter.next()
    
    # This will do a create ...
    Book.objects.get_or_create(id=nextid, defaults={'title': 'hi'})
    
    # ... and this a get.
    Book.objects.get_or_create(id=nextid, defaults={'title': 'hi'})

run_benchmark(benchmark, trials=25)
Example #9
0
from utils import run_benchmark


def benchmark():
    # Make sure the models and settings are loaded, then we're done. Calling
    # get_models() will make sure settings get loaded.
    from django.db import models

    models.get_models()


run_benchmark(benchmark, syncdb=False)
Example #10
0
logging.basicConfig(format='%(message)s', level=logging.DEBUG)

devices = devices.nvidia.enumerate_devices()

stratums = {
    'neoscrypt': 'neoscrypt.usa.nicehash.com:3341',
    'equihash': 'equihash.usa.nicehash.com:3357',
    'daggerhashimoto': 'daggerhashimoto.usa.nicehash.com:3353',
    'pascal': 'pascal.usa.nicehash.com:3358'
    }

my_settings = settings.DEFAULT_SETTINGS
my_settings['nicehash']['wallet'] = '35W1oyYVVEbkAhA7Uz7fJvSvmNGNuVrYEF'

exc = miners.excavator.Excavator(my_settings, stratums)
exc.load()

ns = next(a for a in exc.algorithms if a.algorithms == ['neoscrypt']])
ns.set_devices([devices[0]])
sleep(10)
ns.set_devices([])

eq = next(a for a in exc.algorithms if a.algorithms == ['equihash']])
logging.info('equihash benchmark = ' + str(utils.run_benchmark(eq, devices[0], 30, 60)))

dp = next(a for a in exc.algorithms if a.algorithms == ['daggerhashimoto', 'pascal']])
logging.info('daggerhash-pascal benchmark = ' + str(utils.run_benchmark(dp, devices[0], 30, 60)))

exc.unload()