def block_cranks(records):
    deliveries = []
    syscalls = 0
    deliver = None
    for record in records:
        ty = record['type']
        if (ty == 'deliver'):
            deliver = record
            syscalls = 0
        elif (ty == 'syscall-result'):
            syscalls += 1
        elif (ty == 'deliver-result'):
            if (not deliver):
                log.warn('no deliver? %s', record)
                continue
            dur = (record['time'] - deliver['time'])
            method = (deliver['kd'][2]['method'] if (deliver['kd'][0] == 'message') else None)
            compute = (record['dr'][2]['compute'] if (type(record['dr'][2]) is type({})) else np.nan)
            detail = dict(record, syscalls=syscalls, kd=deliver['kd'], method=method, compute=compute, dur=dur)
            deliveries.append(detail)
    if deliveries:
        return pd.DataFrame.from_records(deliveries)
    else:
        return no_deliveries
def block_cranks(records):
    deliveries = []
    syscalls = 0
    deliver = None
    for record in records:
        ty = record['type']
        if (ty == 'deliver'):
            deliver = record
            syscalls = 0
        elif (ty == 'syscall-result'):
            syscalls += 1
        elif (ty == 'deliver-result'):
            if (not deliver):
                log.warn('no deliver? %s', record)
                continue
            dur = (record['time'] - deliver['time'])
            method = (deliver['kd'][2]['method'] if (deliver['kd'][0] == 'message') else None)
            compute = (record['dr'][2]['compute'] if (type(record['dr'][2]) is type({})) else np.nan)
            detail = dict(record, syscalls=syscalls, kd=deliver['kd'], method=method, compute=compute, dur=dur)
            deliveries.append(detail)
    if deliveries:
        return pd.DataFrame.from_records(deliveries)
    else:
        return no_deliveries