|
|
|
[
Permlink
| « Hide
]
Phong Trinh [10/Dec/25 03:16 AM]
Thank you very much, Robin!
Please use below groovy script. It get latest 10 builds of root configuration, and prints the average build and step duration:
groovy: import com.pmease.quickbuild.SearchCriteria; import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; def statsConf = system.configurationManager.get("root"); def totalBuildDuration = 0; def totalBuildCount = 0; def totalStepDurationMap = [:]; def totalStepCountMap = [:]; def criterions = [Restrictions.eq("configuration", statsConf)] as Criterion[]; for (eachBuild in system.buildManager.search(new SearchCriteria(criterions, new Order[]{Order.desc("id")}), 0, 10)) { if (eachBuild.duration != null) { totalBuildDuration += eachBuild.duration; totalBuildCount++; } for (eachEntry in eachBuild.stepRuntimes.entrySet()) { if (eachEntry.value.duration != null) { totalStepDurationMap[eachEntry.key] = totalStepDurationMap.get(eachEntry.key, 0) + eachEntry.value.duration; totalStepCountMap[eachEntry.key] = totalStepCountMap.get(eachEntry.key, 0) + 1; } } } logger.info("average build duration: " + (totalBuildDuration / totalBuildCount)); for (entry in totalStepDurationMap.entrySet()) { logger.info("average duration for step " + entry.key + ": " + entry.value / totalStepCountMap[entry.key]); } | |||||||||||||||||||||||||||||||||||||||||||||||