def stop(self): stop_time = time.time() if self.start_time: diff = stop_time - self.start_time assert diff > 0 print('time: {}'.format(format_delta(diff)))
def stop(self): delta = monotonic() - self.start_time print( u'time: {} (started: {})'.format( format_delta(delta), format_timestamp(self.timestamp), ) )
def stop_timer(self): if sys.version_info.major == 2: stop_time = time.time() else: stop_time = time.monotonic() if self.start_time: diff = stop_time - self.start_time assert diff > 0 print('time: {}'.format(format_delta(diff)))
def stop(self, result): raw = result.info.raw_cell defs_only = all( re.match('def|class|\s', line) for line in raw.split('\n')) if not defs_only and self.start_time: stop_time = _timer() diff = stop_time - self.start_time assert diff >= 0 print('time: {}'.format(format_delta(diff)))
def stop(self): """Show results.""" if self.start_time: diff = time.time() - self.start_time epoch_start_time = pretty_date_time(self.start_time) epoch_end_time = pretty_date_time(time.time()) assert diff > 0 if diff > 100: print('duration:', epoch_start_time, "\t<->\t", epoch_end_time) # print('\a') system("tput bel") print('time: %s' % format_delta(diff))
def stop(self): if self.start_time: diff = time.time() - self.start_time assert diff > 0 print('time: %s' % format_delta(diff))
def timing(prefix=''): t0 = time.time() yield print(' '.join( [prefix, 'elapsed time: %s' % format_delta(time.time() - t0)]))
def stop(self): delta = monotonic() - self.start_time print(u"\ntime: {}".format(format_delta(delta)))
sc.setLogLevel('debug') import urllib.request url = 'http://kdd.ics.uci.edu/databases/kddcup99/kddcup.data_10_percent.gz' localfile = '/tmp/kddcup.data_10_percent.gz' f = urllib.request.urlretrieve(url, localfile) from time import time from IPython.core.magics.execution import _format_time as format_delta start_time = time() raw_data = sc.textFile('file:///tmp/kddcup.data_10_percent.gz') stop_time = time() print('time: {}'.format(format_delta(stop_time - start_time))) # withReplacement – can elements be sampled multiple times (replaced when sampled out) # fraction – probability that each element is chosen; fraction must be [0, 1] # seed – seed for the random number generator sampled = raw_data.sample(False, 0.1, 42) contains_normal_sample = sampled.map(lambda x: x.split(",")).filter( lambda x: "normal" in x) contains_normal = raw_data.map(lambda x: x.split(',')).filter( lambda x: "normal" in x) start_time = time() contains_normal.count()