All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Seven Methods for Precisely Wasting CPU Time in Java Profiling Tests

By

tanelpoder

8mo ago· 10 min readen

Summary

This technical blog post explores seven different methods to intentionally waste specific amounts of CPU time for testing purposes, particularly in the context of profiling Java applications. The author builds on previous work with CPU-time profilers and demonstrates various approaches to consume precise CPU cycles, ranging from simple loops to more sophisticated techniques involving mathematical operations and system calls.

Key quotes

· 4 pulled
Welcome back to my blog. Last week, I showed you how to profile your Cloudfoundry application, and the week before, how I made the CPU-time profiler a tiny bit better by removing redundant synchronization.
This week's blog post will be closer to the latter, trying to properly waste CPU.
As a short backstory, my profiler needed a test to check that the queue size of the sampler really increased dynamically, so I needed a way to let a thread spend a pre-defined amount of CPU-time.
In this week's blog post, you'll learn seven different ways to waste a specific amount of CPU-time.
Snippet from the RSS feed
In this week's blog post, you'll learn seven different ways to waste a specific amount of CPU-time. Number seven will surprise you.

You might also wanna read