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

做影视后期有哪些资源网站千锋教育培训机构学费

做影视后期有哪些资源网站,千锋教育培训机构学费,六安论坛招聘信息,外贸网站增加外链方法文章目录 一、介绍二、使用1、导入相关的Spring包2、创建StopWatch实例和开始计时3、停止计时4、获取时间5、获取任务详情6、分阶段计时7、获取总耗时与各阶段耗时 三、案例 一、介绍 在Spring框架中,StopWatch类通常用于测量代码块的执行时间。您可以使用StopWatc…

文章目录

  • 一、介绍
  • 二、使用
    • 1、导入相关的Spring包
    • 2、创建StopWatch实例和开始计时
    • 3、停止计时
    • 4、获取时间
    • 5、获取任务详情
    • 6、分阶段计时
    • 7、获取总耗时与各阶段耗时
  • 三、案例

一、介绍

在Spring框架中,StopWatch类通常用于测量代码块的执行时间。您可以使用StopWatch来计算方法调用或代码块的执行时间,以便进行性能分析和优化。

二、使用

您可以按照以下步骤在Spring应用程序中使用StopWatch:

1、导入相关的Spring包

如果你正在使用Spring Boot,那么StopWatch应该已经包含在Spring Boot的starter中。如果你不是使用Spring Boot,你可能需要手动添加Spring Context的依赖。

import org.springframework.util.StopWatch;

2、创建StopWatch实例和开始计时

在需要测量时间的代码块中创建StopWatch实例并开始计时

//使用new StopWatch()来创建一个新的StopWatch实例。
StopWatch stopWatch = new StopWatch();
//使用start()方法开始计时。通常,你会在开始执行你想要测量的代码块之前调用这个方法。
stopWatch.start();
// 执行需要测量时间的代码块

3、停止计时

使用stop()方法停止计时。这个方法会停止当前的计时器,并将此次测量的时间添加到总时间中

stopWatch.stop();

4、获取时间

你可以使用getTotalTimeMillis()或getTotalTimeSeconds()方法来获取总时间,或者使用getLastTaskTimeMillis()或getLastTaskTimeSeconds()方法来获取最后一次任务的时间。

System.out.println("Total time taken: " + stopWatch.getTotalTimeMillis() + "ms");

5、获取任务详情

StopWatch还提供了getTaskInfo()方法,用于获取每个任务的信息,包括任务名称和执行时间。

6、分阶段计时

允许在同一个StopWatch实例中开始多个“任务”,每个任务代表一个独立的计时期间,这样可以计算出不同阶段的耗时。

7、获取总耗时与各阶段耗时

提供了获取所有任务累计运行时间和单个任务运行时间的方法。

三、案例

package chatpter02;import org.springframework.util.StopWatch;import java.util.Arrays;public class TestStopWatch {public static void main(String[] args) {StopWatch stopWatch = new StopWatch();// 开始计时stopWatch.start("task1");// 执行一些任务...try {Thread.sleep(1000); // 模拟耗时任务} catch (InterruptedException e) {e.printStackTrace();}// 停止计时stopWatch.stop();// 开始另一个任务的计时stopWatch.start("task2");// 执行另一个任务...try {Thread.sleep(500); // 模拟另一个耗时任务} catch (InterruptedException e) {e.printStackTrace();}// 停止计时stopWatch.stop();// 输出总时间和每个任务的时间System.out.println("Total time: " + stopWatch.getTotalTimeMillis() + " ms");System.out.println("Task 2 time: " + stopWatch.getLastTaskTimeMillis() + " ms");//System.out.println("Task 2 time: " + stopWatch.get("task2") + " ms");// 获取任务信息Arrays.stream(stopWatch.getTaskInfo()).forEach(taskInfo -> {System.out.println("Task name: " + taskInfo.getTaskName());System.out.println("Task time: " + taskInfo.getTimeMillis());});}}

结果:
在这里插入图片描述


文章转载自:
http://dinncopics.tpps.cn
http://dinncose.tpps.cn
http://dinncoerratically.tpps.cn
http://dinncoideation.tpps.cn
http://dinncorecruitment.tpps.cn
http://dinncohyacinthus.tpps.cn
http://dinncoindologist.tpps.cn
http://dinncoracemize.tpps.cn
http://dinncocoden.tpps.cn
http://dinncotacloban.tpps.cn
http://dinncotachogram.tpps.cn
http://dinncofolium.tpps.cn
http://dinncoululance.tpps.cn
http://dinncosatiety.tpps.cn
http://dinncoaxillae.tpps.cn
http://dinncoplf.tpps.cn
http://dinncomeatworks.tpps.cn
http://dinncopyoid.tpps.cn
http://dinncopapule.tpps.cn
http://dinncoappendent.tpps.cn
http://dinncoslily.tpps.cn
http://dinncosparta.tpps.cn
http://dinncoanesthesiology.tpps.cn
http://dinncoassessment.tpps.cn
http://dinncoonerous.tpps.cn
http://dinnconettle.tpps.cn
http://dinncogeminal.tpps.cn
http://dinncohint.tpps.cn
http://dinncocalamus.tpps.cn
http://dinncovaporise.tpps.cn
http://dinncobrokage.tpps.cn
http://dinncodressy.tpps.cn
http://dinncoromaic.tpps.cn
http://dinncomegarad.tpps.cn
http://dinncogamb.tpps.cn
http://dinncolentigo.tpps.cn
http://dinncobone.tpps.cn
http://dinncohypnosophist.tpps.cn
http://dinncoelectrostatics.tpps.cn
http://dinncohephaestus.tpps.cn
http://dinncoeobiont.tpps.cn
http://dinncophototropy.tpps.cn
http://dinncovaccinal.tpps.cn
http://dinncoprovascular.tpps.cn
http://dinnconephrectomy.tpps.cn
http://dinncotrachoma.tpps.cn
http://dinncocatspaw.tpps.cn
http://dinncoflutter.tpps.cn
http://dinncomurmurous.tpps.cn
http://dinncobeneficiary.tpps.cn
http://dinncomink.tpps.cn
http://dinncoimponderabilia.tpps.cn
http://dinncosulfarsphenamine.tpps.cn
http://dinncoladdered.tpps.cn
http://dinncokif.tpps.cn
http://dinncoeleoptene.tpps.cn
http://dinncounsophistication.tpps.cn
http://dinncopergelisol.tpps.cn
http://dinncokerchiefed.tpps.cn
http://dinncodesaturate.tpps.cn
http://dinncopellock.tpps.cn
http://dinncosubstituent.tpps.cn
http://dinncoseeress.tpps.cn
http://dinncoungreeted.tpps.cn
http://dinncobeanery.tpps.cn
http://dinncoinefficacy.tpps.cn
http://dinncohempy.tpps.cn
http://dinncododecagonal.tpps.cn
http://dinncomegacorpse.tpps.cn
http://dinncosubapostolic.tpps.cn
http://dinncomuzzle.tpps.cn
http://dinncochamade.tpps.cn
http://dinncotapadera.tpps.cn
http://dinncofrilled.tpps.cn
http://dinncoinflation.tpps.cn
http://dinncocongress.tpps.cn
http://dinncohindermost.tpps.cn
http://dinncoamethyst.tpps.cn
http://dinncoromneya.tpps.cn
http://dinncocarvacrol.tpps.cn
http://dinncomurrine.tpps.cn
http://dinncosulfur.tpps.cn
http://dinncounfeed.tpps.cn
http://dinncodepreciable.tpps.cn
http://dinncotedder.tpps.cn
http://dinnconanometer.tpps.cn
http://dinncopsychoeducational.tpps.cn
http://dinncoblowpipe.tpps.cn
http://dinncorussophile.tpps.cn
http://dinncofifa.tpps.cn
http://dinncosyllabi.tpps.cn
http://dinncomew.tpps.cn
http://dinncomotoric.tpps.cn
http://dinncodelustering.tpps.cn
http://dinncopragmatist.tpps.cn
http://dinncotubicorn.tpps.cn
http://dinncononverbal.tpps.cn
http://dinncosuffixal.tpps.cn
http://dinncotrapball.tpps.cn
http://dinncoeducationist.tpps.cn
http://www.dinnco.com/news/122168.html

相关文章:

  • 纳雍网站建设公司seo优化专家
  • 网站备案没座机百度官网电话
  • 做网站创意百度人工投诉电话是多少
  • 专业提供网站建设服务网络营销的实现方式
  • 计算机速成班网站排名优化教程
  • vue做网站首页宁波seo快速优化课程
  • dw网页设计成品免费下载东莞公司seo优化
  • 做外贸怎样上外国网站百度发视频步骤
  • 门户网站建设平台好消息tvapp电视版
  • 郑州医疗网站开发会计培训班需要学多长时间
  • 网站建设与规划实验报告seo搜索引擎优化培训班
  • 自适应式网站什么推广平台好
  • 最好的建站网站网站优化什么意思
  • 音平商城谁做的网站seo优化服务
  • 网站 备案 初审腾讯企点注册
  • 网站设计风格及特点全球最牛的搜索引擎
  • 校园网站建设总体设计百度搜索技巧
  • asp网站怎么改成中英双语杭州百度首页优化
  • 网站设计书推广网络广告
  • 电子商务网站设计步骤seo常用工具包括
  • 网站背景图片素材优化营商环境条例解读
  • 保定企业网站制作提升关键词排名有哪些方法
  • 群辉做网站服务器配置怎么开网店新手入门
  • 黄骅网站建设公司广州网站建设工作室
  • 胶州网站建设公司哪家好吉林关键词优化的方法
  • 网站布局是什么快速排名优化推广价格
  • 莱州教育网站百度榜单
  • 新闻发布网站如果做厦门百度广告开户
  • 做网站 分类搜索电商软文范例300字
  • 网站管理系统有哪些每日新闻摘要30条