当前位置: 首页 > news >正文

南阳微网站制作开发公司制度

南阳微网站制作,开发公司制度,购物网站后台管理模板,抖音引流推广软件我正在编写一个简单的应用程序#xff0c;它将大文本文件拆分为较小的文件#xff0c;并且我已经编写了2个版本#xff0c;一个使用列表#xff0c;另一个使用生成器。我使用memory_profiler模块对这两个版本进行了概要分析#xff0c;并清楚地显示了生成器版本的更好的内…我正在编写一个简单的应用程序它将大文本文件拆分为较小的文件并且我已经编写了2个版本一个使用列表另一个使用生成器。我使用memory_profiler模块对这两个版本进行了概要分析并清楚地显示了生成器版本的更好的内存效率但是在对使用生成器的版本进行概要分析时这很奇怪这增加了执行时间。下面的演示解释了我的意思 使用列表版本 frommemory_profilerimportprofileprofile()defmain():file_nameinput(Enter the full path of file you want to split into smaller inputFiles: )input_fileopen(file_name).readlines()num_lines_origlen(input_file)partsint(input(Enter the number of parts you want to split in: ))output_files[(file_namestr(i))foriinrange(1,parts1)]st0pint(num_lines_orig/parts)edpforiinrange(parts-1):withopen(output_files[i],w)asOF:OF.writelines(input_file[st:ed])sted edstpwithopen(output_files[-1],w)asOF:OF.writelines(input_file[st:])if__name____main__:main() 与分析器一起运行时 $ time py36Splitting\ text\ files_BAD_usingLists.pyEnterthe full path of file you want to split into smaller inputFiles:/apps/nttech/rbhanot/Downloads/test.txtEnterthe number of parts you want to splitin:3Filename:Splittingtext files_BAD_usingLists.pyLine# Mem usage Increment Line Contents647.8MiB0.0MiBprofile()7defmain():847.8MiB0.0MiBfile_nameinput(Enter the full path of file you want to split into smaller inputFiles: )9107.3MiB59.5MiBinput_fileopen(file_name).readlines()10107.3MiB0.0MiBnum_lines_origlen(input_file)11107.3MiB0.0MiBpartsint(input(Enter the number of parts you want to split in: ))12107.3MiB0.0MiBoutput_files[(file_namestr(i))foriinrange(1,parts1)]13107.3MiB0.0MiBst014107.3MiB0.0MiBpint(num_lines_orig/parts)15107.3MiB0.0MiBedp16108.1MiB0.7MiBforiinrange(parts-1):17107.6MiB-0.5MiBwithopen(output_files[i],w)asOF:18108.1MiB0.5MiBOF.writelines(input_file[st:ed])19108.1MiB0.0MiBsted20108.1MiB0.0MiBedstp2122108.1MiB0.0MiBwithopen(output_files[-1],w)asOF:23108.1MiB0.0MiBOF.writelines(input_file[st:])real0m6.115suser0m0.764ssys0m0.052s 在没有分析器的情况下运行 $ time py36Splitting\ text\ files_BAD_usingLists.pyEnterthe full path of file you want to split into smaller inputFiles:/apps/nttech/rbhanot/Downloads/test.txtEnterthe number of parts you want to splitin:3real0m5.916suser0m0.696ssys0m0.080s 现在使用发电机 profile()defmain():file_nameinput(Enter the full path of file you want to split into smaller inputFiles: )input_fileopen(file_name)num_lines_origsum(1for_ininput_file)input_file.seek(0)partsint(input(Enter the number of parts you want to split in: ))output_files((file_namestr(i))foriinrange(1,parts1))st0pint(num_lines_orig/parts)edpforiinrange(parts-1):filenext(output_files)withopen(file,w)asOF:for_inrange(st,ed):OF.writelines(input_file.readline())sted edstpifnum_lines_orig-ed filenext(output_files)withopen(file,w)asOF:for_inrange(st,ed):OF.writelines(input_file.readline())if__name____main__:main() 使用分析器选项运行时 $ time py36-m memory_profilerSplitting\ text\ files_GOOD_usingGenerators.pyEnterthe full path of file you want to split into smaller inputFiles:/apps/nttech/rbhanot/Downloads/test.txtEnterthe number of parts you want to splitin:3Filename:Splittingtext files_GOOD_usingGenerators.pyLine# Mem usage Increment Line Contents447.988MiB0.000MiBprofile()5defmain():647.988MiB0.000MiBfile_nameinput(Enter the full path of file you want to split into smaller inputFiles: )747.988MiB0.000MiBinput_fileopen(file_name)847.988MiB0.000MiBnum_lines_origsum(1for_ininput_file)947.988MiB0.000MiBinput_file.seek(0)1047.988MiB0.000MiBpartsint(input(Enter the number of parts you want to split in: ))1148.703MiB0.715MiBoutput_files((file_namestr(i))foriinrange(1,parts1))1247.988MiB-0.715MiBst01347.988MiB0.000MiBpint(num_lines_orig/parts)1447.988MiB0.000MiBedp1548.703MiB0.715MiBforiinrange(parts-1):1648.703MiB0.000MiBfilenext(output_files)1748.703MiB0.000MiBwithopen(file,w)asOF:1848.703MiB0.000MiBfor_inrange(st,ed):1948.703MiB0.000MiBOF.writelines(input_file.readline())202148.703MiB0.000MiBsted2248.703MiB0.000MiBedstp2348.703MiB0.000MiBifnum_lines_orig-ed
http://www.pierceye.com/news/739923/

相关文章:

  • 网站后台有什么用wordpress 不显示账号名
  • 另类小说 Wordpress长沙seo步骤
  • 网站建设7个基37网游官网
  • 网站设计存在的问题建筑设计私活平台
  • 网站如何做淘宝支付宝wordpress多站点不显示
  • 关于设计的网站免费注册公司
  • 网站建设排名北京网站排名降级的原因有哪些
  • 介绍网页设计做seo推广网站
  • 建立个人博客网站wordpress东城东莞网站建设
  • 从哪些方面建设网站泰州东方医院
  • 分类信息网站系统cmsWordPress新闻面包屑主题
  • wordpress 多标签关键字优化策略
  • idea15网站开发网站如何提升seo排名
  • 谁有网站推荐一下好安阳刚刚发生的事
  • 博客网站快速排名临邑县住房和城乡建设局网站
  • 二手网站建设方案营销网站建设服务平台
  • 遵化建设局网站濮阳新闻综合频道
  • 百度云如何做网站论文网站建设与运营
  • 网站开发环境实验报告注册公司流程和费用是多少
  • 下载一个网站学院网站建设的作用
  • 济南专业网站优化花西子的网络营销策略
  • 武城网站建设费用网页设计试题及答案
  • 郑州外贸网站建设公司搜索引擎排名的三大指标
  • 温州专业微网站制作电台 主题 wordpress
  • wordpress做网站过程阳江网上车管所
  • 网站抓取qq上海自贸区注册公司流程
  • 深圳网站设计推荐刻烟台制作网站有哪些
  • 网站注册系统源码卢松松博客源码 wordpress博客模板
  • 网站开发进阶实训报告廊坊安次区网站建设公司
  • jquery插件网站推荐打开网站自动跳转代码