Best Python code snippet using Airtest
xlsx.py
Source:xlsx.py
...238 self.benchmarks.write_comment(f'{letter}{last_row + 1}', comments[index])239 def _create_graphs(self):240 self._create_avg_latency_graph()241 self._create_mean_latency_by_location_graph()242 def _get_graph_title(self, title: str) -> str:243 if self.graphs_title_prefix:244 return f'{self.graphs_title_prefix} - {title}'245 return title246 def _create_mean_latency_by_location_graph(self):247 workbook = self.workbook248 chart = workbook.add_chart({'type': 'column'})249 sheet = self.mean_latency_by_location250 sheet_name = sheet.name251 chart.add_series({252 'name': f'={sheet_name}!$B$1',253 'categories': f'={sheet_name}!$A$2:$A${sheet.row}',254 'values': f'={sheet_name}!$B$2:$B${sheet.row}'255 })256 chart.set_title({'name': self._get_graph_title('Latency mean (ms)')})257 chart.x_scale = 2.5258 chart.y_scale = 2.5259 self.mean_latency_by_location.insert_chart('E2', chart, {'x_offset': 0, 'y_offset': 0})260 chart.set_style(self.chart_style)261 def _create_avg_latency_graph(self):262 workbook = self.workbook263 chart = workbook.add_chart({'type': 'line'})264 sheet = self.avg_latency265 sheet_name = sheet.name266 chart.add_series({267 'name': f'={sheet_name}!$C$1',268 'categories': f'={sheet_name}!$A$2:$A${sheet.row}',269 'values': f'={sheet_name}!$C$2:$C${sheet.row}'270 })271 chart.set_title({'name': self._get_graph_title('Avg. latency (ms)')})272 chart.x_scale = 2.5273 chart.y_scale = 2.5274 chart.set_x_axis({'text_axis': True})275 self.avg_latency.insert_chart('E2', chart, {'x_offset': 0, 'y_offset': 0})276 chart.set_style(self.chart_style)277 def close(self):278 self._write_avg_latencies_by_location()279 self._write_formulas()280 self._create_graphs()...
plot.py
Source:plot.py
...82 method_index += 1 # è¿è¡ä¸ä¸ä¸ªæ¹æ³æ¶:å½åæ¹æ³çåºå·+183 continue84 else:85 break86 def _get_graph_title(self):87 """è·åå¾åçtitle."""88 start_time = datetime.fromtimestamp(int(self.timestamp_list[0]))89 end_time = datetime.fromtimestamp(int(self.timestamp_list[-1]))90 end_time = end_time.strftime('%H:%M:%S')91 title = "Timespan: %s ââ %s" % (start_time, end_time)92 return title93 def plot_cpu_mem_keypoints(self):94 """ç»å¶CPU/Mem/ç¹å¾ç¹æ°é."""95 plt.figure(1)96 # å¼å§ç»å¶åå¾:97 plt.subplot(311)98 title = self._get_graph_title()99 plt.title(title, loc="center") # 设置ç»å¾çæ é¢100 mem_ins = plt.plot(self.time_axis, self.mem_axis, "-", label="Mem(MB)", color='deepskyblue', linestyle='-', marker=',')101 # 设置æ°åæ ç¾102 plt.legend(mem_ins, ["Mem(MB)"], loc='upper right') # 说ææ ç¾çä½ç½®103 plt.grid() # å ç½æ ¼104 plt.ylabel("Mem(MB)")105 plt.ylim(bottom=0)106 for method_exec in self.method_exec_info:107 start_date = datetime.fromtimestamp(method_exec["start_time"])108 end_date = datetime.fromtimestamp(method_exec["end_time"])109 plt.vlines(start_date, 0, self.max_mem, colors="c", linestyles="dashed") # vlines(x, ymin, ymax)110 plt.vlines(end_date, 0, self.max_mem, colors="c", linestyles="dashed") # vlines(x, ymin, ymax)111 # ç»å¶memæå:112 x = datetime.fromtimestamp(method_exec["mem_max_time"])...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!