org.springframework.util.StopWatch使用说明

StopWatch是一个用于测量代码执行时间和性能的工具类。通过创建对象,启动和停止计时,可以获取代码块的执行时间。它支持间隔计时,保留任务清单,以及打印格式化的执行时间报告。此外,StopWatch还提供重置功能,以便重复使用。

StopWatch是一个简单实用的秒表工具类,可以用来评估代码块的执行时间和性能。
以下是StopWatch的主要用法:

  1. 创建StopWatch对象
StopWatch stopWatch = new StopWatch();
StopWatch stopWatch2 = new StopWatch("读取商品信息");
  1. 启动秒表计时
stopWatch.start(); 
  1. 执行需要计时的代码块
  2. 停止秒表计时
stopWatch.stop(
2025-07-11 09:54:15.937 ERROR 13820 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: An attempt was made to call a method that does not exist. The attempt was made from the following location: org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:210) The following method did not exist: 'org.springframework.util.StopWatch$TaskInfo org.springframework.util.StopWatch.lastTaskInfo()' The calling method's class, org.springframework.data.repository.config.RepositoryConfigurationDelegate, was loaded from the following location: jar:file:/C:/Users/20651/.m2/repository/org/springframework/data/spring-data-commons/3.2.0/spring-data-commons-3.2.0.jar!/org/springframework/data/repository/config/RepositoryConfigurationDelegate.class The called method's class, org.springframework.util.StopWatch, is available from the following locations: jar:file:/C:/Users/20651/.m2/repository/org/springframework/spring-core/5.3.33/spring-core-5.3.33.jar!/org/springframework/util/StopWatch.class The called method's class hierarchy was loaded from the following locations: org.springframework.util.StopWatch: file:/C:/Users/20651/.m2/repository/org/springframework/spring-core/5.3.33/spring-core-5.3.33.jar Action: Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.data.repository.config.RepositoryConfigurationDelegate and org.springframework.util.StopWatch 进程已结束,退出代码为 1
最新发布
07-12
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

刘彦青-Yannis

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

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

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

打赏作者

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

抵扣说明:

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

余额充值