python c++读取网络图片性能对比

这篇博客对比了Python和C++在读取网络图片时的性能。结果显示,C++的平均响应时间远低于Python,最快甚至达到0ms。
摘要由CSDN通过智能技术生成

 

 

import time
import numpy as np

import cv2
import requests


urls=["http://www.pptbz.com/pptpic/UploadFiles_6909/201203/2012031220134655.jpg","http://pic22.nipic.com/20120714/9622064_105642209176_2.jpg","http://pic104.nipic.com/file/20160715/6171480_185807154956_2.jpg",

"http://www.pptbz.com/pptpic/UploadFiles_6909/201203/2012031220134655.jpg"]

for i in urls:
    start=time.time()
    file = requests.get(i)
    img = cv2.imdecode(np.fromstring(file.content, np.uint8), 1)    #file.content 是读取的远程文件的字节流
    print('time',time.time()-start)

时间:

time 0.4249999523162842
time 0.546999454498291
time 0.5099942684173584
time 0.3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值