<s> import os <EOL> import sys <EOL> import random <EOL> import argparse <EOL> import numpy as np <EOL> import tempfile <EOL> import h5py <EOL> import urllib2 <EOL> import zlib <EOL> import cStringIO <EOL> import blosc <EOL> import time <EOL> import json <EOL> from operator import add , sub , mul <EOL> from functools import reduce <EOL> sys . path += [ os . path . abspath ( '<STR_LIT>' ) ] <EOL> import OCP . settings <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> from ocplib import MortonXYZ <EOL> def getURL ( url ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> req = urllib2 . Request ( url ) <EOL> start = time . time ( ) <EOL> response = urllib2 . urlopen ( req ) <EOL> print time . time ( ) - start <EOL> return response <EOL> except urllib2 . HTTPError , e : <EOL> print "<STR_LIT>" <EOL> return e <EOL> class BenchmarkTest : <EOL> def __init__ ( self , host , token , channel , resolution ) : <EOL> """<STR_LIT>""" <EOL> self . host = host <EOL> self . token = token <EOL> self . channels = [ channel ] <EOL> self . resolution = resolution <EOL> self . getProjInfo ( ) <EOL> def readTest ( self , start_value = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , number_iteration = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> min_values = [ xmin , ymin , zmin ] = map ( add , self . offset , start_value ) <EOL> max_values = map ( add , min_values , self . dim ) <EOL> range_args = [ None ] * ( len ( min_values ) + len ( max_values ) ) <EOL> for i in range ( <NUM_LIT:0> , number_iteration , <NUM_LIT:1> ) : <EOL> range_args [ : : <NUM_LIT:2> ] = min_values <EOL> range_args [ <NUM_LIT:1> : : <NUM_LIT:2> ] = max_values <EOL> self . getBlosc ( range_args ) <EOL> min_values [ <NUM_LIT:2> ] = max_values [ <NUM_LIT:2> ] <EOL> max_values [ <NUM_LIT:2> ] = min_values [ <NUM_LIT:2> ] + self . dim [ <NUM_LIT:2> ] <EOL> max_values [ ( i + <NUM_LIT:1> ) % <NUM_LIT:2> ] = start_value [ ( i + <NUM_LIT:1> ) % <NUM_LIT:2> ] + ( max_values [ ( i + <NUM_LIT:1> ) % <NUM_LIT:2> ] - min_values [ ( i + <NUM_LIT:1> ) % <NUM_LIT:2> ] ) * <NUM_LIT:2> <EOL> def getProjInfo ( self ) : <EOL> """<STR_LIT>""" <EOL> url = '<STR_LIT>' . format ( self . host , self . token ) <EOL> f = getURL ( url ) <EOL> info = json . loads ( f . read ( ) ) <EOL> self . dim = info [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ self . resolution ] <EOL> self . imagesize = info [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ self . resolution ] <EOL> self . offset = info [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ self . resolution ] <EOL> def getBlosc ( self , range_args ) : <EOL> """<STR_LIT>""" <EOL> url = '<STR_LIT>' . format ( self . host , self . token , '<STR_LIT:U+002C>' . join ( self . channels ) , self . resolution , * range_args ) <EOL> getURL ( url ) <EOL> def main ( ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( description = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT:host>' , action = "<STR_LIT:store>" , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , action = "<STR_LIT:store>" , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , action = "<STR_LIT:store>" , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , action = "<STR_LIT:store>" , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , nargs = <NUM_LIT:3> , type = int , metavar = ( '<STR_LIT:x>' , '<STR_LIT:y>' , '<STR_LIT:z>' ) , default = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , help = '<STR_LIT>' ) <EOL> result = parser . parse_args ( ) <EOL> bt = BenchmarkTest ( result . host , result . token , result . channel , result . resolution ) <EOL> bt . readTest ( start_value = result . offset ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
