Best Python code snippet using Airtest
plot.py
Source: plot.py
...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"])113 text = "%s: %d MB" % (method_exec["name"], method_exec["mem_max"])114 plt.text(x, method_exec["mem_max"], text, ha="center", va="bottom", fontsize=10)115 plt.plot(x, method_exec["mem_max"], 'bo', label="point") # ç»å¶ç¹116 # ç»å¶åå¾2117 plt.subplot(312)118 cpu_ins = plt.plot(self.time_axis, self.cpu_axis, "-", label="CPU(%)", color='red', linestyle='-', marker=',')119 plt.legend(cpu_ins, ["CPU(%)"], loc='upper right') # 说ææ ç¾çä½ç½®120 plt.grid() # å ç½æ ¼121 plt.xlabel("Time(s)")122 plt.ylabel("CPU(%)")123 plt.ylim(0, 120)124 for method_exec in self.method_exec_info:125 start_date = datetime.fromtimestamp(method_exec["start_time"])126 end_date = datetime.fromtimestamp(method_exec["end_time"])127 plt.vlines(start_date, 0, 100, colors="c", linestyles="dashed") # vlines(x, ymin, ymax)128 plt.vlines(end_date, 0, 100, colors="c", linestyles="dashed") # vlines(x, ymin, ymax)129 # ç»å¶memæå:130 x = datetime.fromtimestamp(method_exec["cpu_max_time"])131 text = "%s: %d%%" % (method_exec["name"], method_exec["cpu_max"])132 plt.text(x, method_exec["cpu_max"], text, ha="center", va="bottom", fontsize=10)133 plt.plot(x, method_exec["cpu_max"], 'ro', label="point") # ç»å¶ç¹134 # ç»å¶åå¾3135 plt.subplot(313) # ç»å¶ä¸ä¸æ±ç¶å¾(å
³é®ç¹)136 # 设置轴åæ ç¾137 plt.xlabel('methods')138 plt.ylabel('keypoints number')139 method_list, method_pts_length_list, color_list = [], [], []140 for method_exec in self.method_exec_info:141 for item in ["kp_sch", "kp_src", "good"]:142 method_list.append("%s-%s" % (method_exec["name"], item))143 method_pts_length_list.append(method_exec[item])144 if method_exec["result"]:145 color_list.append(["palegreen", "limegreen", "deepskyblue"][["kp_sch", "kp_src", "good"].index(item)])146 else:147 color_list.append("tomato")148 method_x = np.arange(len(method_list)) + 1149 plt.bar(method_x, method_pts_length_list, width=0.35, align='center', color=color_list, alpha=0.8)150 plt.xticks(method_x, method_list, size='small', rotation=30)151 # 设置æ°åæ ç¾152 for x, y in zip(method_x, method_pts_length_list):153 plt.text(x, y + 10, "%d" % y, ha="center", va="bottom", fontsize=7)154 plt.ylim(0, max(method_pts_length_list) * 1.2)155 # æ¾ç¤ºå¾å156 plt.show()157def main():158 # ç»å¶ç»æå¾159 plot_object = PlotResult(dir_path="result", file_name="high_dpi.json")160 plot_object.plot_cpu_mem_keypoints()161if __name__ == '__main__':...
Check out the latest blogs from LambdaTest on this topic:
Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.
The purpose of developing test cases is to ensure the application functions as expected for the customer. Test cases provide basic application documentation for every function, feature, and integrated connection. Test case development often detects defects in the design or missing requirements early in the development process. Additionally, well-written test cases provide internal documentation for all application processing. Test case development is an important part of determining software quality and keeping defects away from customers.
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
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!!