def analyze_value()

in contrib/profiler/profiler.py [0:0]


def analyze_value(sample_datas, period, gpu_id):
    sample_datas = np.array(sample_datas)
    gpu_nums = len(gpu_id)

    # analyze the CPU usage
    # index 0 is the CPU usage
    cpu_usage = np.sort(sample_datas[:, SAMPLE_INFO.cpu_usage.value])
    print('For the CPU, here is the analyze result:')
    print('The max value of the CPU Utilization is', str(np.max(cpu_usage)) + '%')
    print('The min value of the CPU Utilization is', str(np.min(cpu_usage)) + '%')
    print('The average value of the CPU Utilization is', str(np.average(cpu_usage)) + '%')
    print('The standard deviation of the CPU Utilization is', str(np.std(cpu_usage)) + '%')
    print('Less than 50% value is more than', str(cpu_usage[int(0.5 * cpu_usage.shape[0])]) + '%')
    print('Less than 20% value is more than', str(cpu_usage[int(0.8 * cpu_usage.shape[0])]) + '%')
    print('===================================================================')

    # analyze the Disk
    # index 3 and 4 are the Disk read and write
    disk_read = np.sort(sample_datas[:, SAMPLE_INFO.io_read.value])
    disk_write = np.sort(sample_datas[:, SAMPLE_INFO.io_write.value])
    print('For the Disk, here is the analyze result:')
    print('The max value of the Disk read is', str(np.max(disk_read)) + 'KBps')
    min_read = 0
    for i in range(disk_read.shape[0]):
        min_read = disk_read[i]
        if min_read > 0:
            break
    print('The min value of the Disk read (without zero) is', str(min_read) + 'KBps')
    print('The max value of the Disk write is', str(np.max(disk_write)) + 'KBps')
    min_write = 0
    for i in range(disk_write.shape[0]):
        min_write = disk_write[i]
        if min_write > 0:
            break
    print('The min value of the Disk write (without zero) is', str(min_write) + 'KBps')
    print('The total read volume of the Disk is', str(np.sum(disk_read) * period) + 'KB')
    print('The total write volume of the Disk is', str(np.sum(disk_write) * period) + 'KB')
    print('===================================================================')

    # analyze the Network
    # index 5 and 6 are the Network inbound and outbound
    network_inbound = np.sort(sample_datas[:, SAMPLE_INFO.network_inbound.value])
    network_outbound = np.sort(sample_datas[:, SAMPLE_INFO.network_outbound.value])
    print('For the Network, here is the analyze result:')
    print('The max value of the Network Inbound is', str(np.max(network_inbound)) + 'KBps')
    min_inbound = 0
    for i in range(network_inbound.shape[0]):
        min_inbound = network_inbound[i]
        if min_inbound > 0:
            break
    print('The min value of the Network Inbound (without zero) is', str(min_inbound) + 'KBps')
    print('The max value of the Network Outbound is', str(np.max(network_outbound)) + 'KBps')
    min_outbound = 0
    for i in range(network_outbound.shape[0]):
        min_outbound = network_outbound[i]
        if min_outbound > 0:
            break
    print('The min value of the Network Outbound (without zero) is', str(min_outbound) + 'KBps')
    print('The total Inbound volume of the Network is', str(np.sum(network_inbound) * period) + 'KB')
    print('The total Outbound volume of the Network is', str(np.sum(network_outbound) * period) + 'KB')
    print('===================================================================')

    print('For the GPU, here is the analyze result:')
    print('The total number of the GPU cards is', gpu_nums)
    print('===================================================================')

    # analyze the GPU memory
    print('For the GPU memory:')
    for i in range(gpu_nums):
        total_gpu_mem = np.max(sample_datas[:, GPU_INFO_OFFSET + GPU_MEM_OFFSET + 1 + INFO_NUM_PER_GPU * i])
        max_gpu_men = np.max(sample_datas[:, GPU_INFO_OFFSET + GPU_MEM_OFFSET + INFO_NUM_PER_GPU * i])
        print('The memory Utilization of Card Index ', gpu_id[i], 'is %.4f%%' % (max_gpu_men / total_gpu_mem * 100))
    print('===================================================================')

    # analyze the GPU usage
    gpu_usage = np.sort(sample_datas[:, GPU_INFO_OFFSET])
    print('For the GPU utilization, we choose the master card to calculate the result.')
    print('The max value of the GPU Utilization is', str(np.max(gpu_usage)) + '%')
    print('The min value of the GPU Utilization is', str(np.min(gpu_usage)) + '%')
    print('The average value of the GPU Utilization is', str(np.average(gpu_usage)) + '%')
    print('The standard deviation of the GPU Utilization is', str(np.std(gpu_usage)) + '%')
    print('Less than 50% value is more than', str(gpu_usage[int(0.5 * gpu_usage.shape[0])]) + '%')
    print('Less than 20% value is more than', str(gpu_usage[int(0.8 * gpu_usage.shape[0])]) + '%')