如何解决为什么python在保存第二次图像时会花费更多时间?
我想在硬盘上保存一个png图像。第一次是1.6秒,而第二次是3秒多,为什么?
import appium.webdriver
from appium import webdriver
import time
import PIL
from PIL import Image
import datetime
"""
Desired Capabilities
"""
desired_cap = {
"deviceName": "ZY2244B53V","platformName": "Android","appPackage": "==","appActivity": "com.tictok.tictokgame.activities.HomeActivity","automationName": "UiAutomator1"
}
webdriver = webdriver.Remote("http://localhost:4723/wd/hub",desired_cap)
n=0
while n<2:
a=datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
print("time of start saving image" + str(a))
webdriver.save_screenshot("D:/Python/winzo_memory/a.png")
b=datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
print("time of end saving image" + str(b))
a=datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
print("time of start opening image" + str(a))
im = Image.open("a.png")
b=datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
print("time of end opening image" + str(b))
n=n+1
输出:
time of start saving image2020-08-23 06:56:41.252
time of end saving image2020-08-23 06:56:42.837
time of start saving image2020-08-23 06:56:42.904
time of end saving image2020-08-23 06:56:45.952
我正在尝试在appium驱动程序中截屏。有没有更快的方法来截屏并让python读取像素?预先感谢。
我的操作系统是Windows7。图像是1080X1920。图像的大小是aprx 1.5 mb。不确定HDD或SSD。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。