1484543d1Sopenharmony_ci#!/usr/bin/env python3 2484543d1Sopenharmony_ci# coding=utf-8 3484543d1Sopenharmony_ci# Copyright (c) 2023 Huawei Device Co., Ltd. 4484543d1Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 5484543d1Sopenharmony_ci# you may not use this file except in compliance with the License. 6484543d1Sopenharmony_ci# You may obtain a copy of the License at 7484543d1Sopenharmony_ci# 8484543d1Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 9484543d1Sopenharmony_ci# 10484543d1Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 11484543d1Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 12484543d1Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13484543d1Sopenharmony_ci# See the License for the specific language governing permissions and 14484543d1Sopenharmony_ci# limitations under the License. 15484543d1Sopenharmony_ci 16484543d1Sopenharmony_ciimport os 17484543d1Sopenharmony_ciimport sys 18484543d1Sopenharmony_ciimport logging 19484543d1Sopenharmony_ciimport pandas 20484543d1Sopenharmony_cifrom matplotlib import pyplot as plt 21484543d1Sopenharmony_ci 22484543d1Sopenharmony_ci 23484543d1Sopenharmony_cidef plot_current_olny(argv): 24484543d1Sopenharmony_ci current_data = argv[1] 25484543d1Sopenharmony_ci fig = plt.figure() 26484543d1Sopenharmony_ci 27484543d1Sopenharmony_ci current = pandas.read_csv(current_data, delim_whitespace=True) 28484543d1Sopenharmony_ci plt.plot(current['duration'], current['sched_time'], 29484543d1Sopenharmony_ci color='r', marker='o', linestyle='-', label='current') 30484543d1Sopenharmony_ci 31484543d1Sopenharmony_ci avg = sum(current['sched_time']) / len(current['sched_time']) 32484543d1Sopenharmony_ci 33484543d1Sopenharmony_ci plt.xlabel('task_duration(us)') 34484543d1Sopenharmony_ci plt.ylabel('sched_time(us)') 35484543d1Sopenharmony_ci plt.title(''.join( 36484543d1Sopenharmony_ci ['ffrt sched_time test [avg:', str(round(avg, 2)), ' us]']), fontsize=20) 37484543d1Sopenharmony_ci plt.savefig("serial_sched_time.jpg") 38484543d1Sopenharmony_ci 39484543d1Sopenharmony_ci 40484543d1Sopenharmony_cidef plot_current_vs_base(argv): 41484543d1Sopenharmony_ci current_data = argv[1] 42484543d1Sopenharmony_ci if len(argv) <= 2: 43484543d1Sopenharmony_ci logging.warning('no base data') 44484543d1Sopenharmony_ci return 45484543d1Sopenharmony_ci else: 46484543d1Sopenharmony_ci base_data = argv[2] 47484543d1Sopenharmony_ci fig = plt.figure() 48484543d1Sopenharmony_ci 49484543d1Sopenharmony_ci base = pandas.read_csv(base_data, delim_whitespace=True) 50484543d1Sopenharmony_ci base_avg = sum(base['sched_time']) / len(base['sched_time']) 51484543d1Sopenharmony_ci plt.plot(base['duration'], base['sched_time'], color='b', 52484543d1Sopenharmony_ci marker='s', linestyle='-.', label=''.join(['base avg:', str(round(base_avg, 2))])) 53484543d1Sopenharmony_ci 54484543d1Sopenharmony_ci current = pandas.read_csv(current_data, delim_whitespace=True) 55484543d1Sopenharmony_ci current_avg = sum(current['sched_time']) / len(current['sched_time']) 56484543d1Sopenharmony_ci plt.plot(current['duration'], current['sched_time'], 57484543d1Sopenharmony_ci color='r', marker='o', linestyle='-', label=''.join(['current avg:', str(round(current_avg, 2))])) 58484543d1Sopenharmony_ci 59484543d1Sopenharmony_ci ratio = (current_avg - base_avg) / base_avg 60484543d1Sopenharmony_ci 61484543d1Sopenharmony_ci plt.legend(loc='best') 62484543d1Sopenharmony_ci plt.xlabel('task_duration(us)') 63484543d1Sopenharmony_ci plt.ylabel('sched_time(us)') 64484543d1Sopenharmony_ci plt.title(''.join(['ffrt serial sched time vs base [Ratio:', str( 65484543d1Sopenharmony_ci round(ratio * 100, 2)), '%]']), fontsize=15) 66484543d1Sopenharmony_ci plt.savefig("serial_sched_time_vs_base.jpg") 67484543d1Sopenharmony_ci 68484543d1Sopenharmony_ci 69484543d1Sopenharmony_ciif __name__ == '__main__': 70484543d1Sopenharmony_ci plot_current_vs_base(sys.argv) 71484543d1Sopenharmony_ci plot_current_olny(sys.argv) 72