diff --git a/miosix/util/util.cpp b/miosix/util/util.cpp
index 656cfb136d13e5f8946c1dd90b4a2558cd075726..b40103269886d6bb930950d5abb0c1fffa389e3d 100644
--- a/miosix/util/util.cpp
+++ b/miosix/util/util.cpp
@@ -174,6 +174,26 @@ long long CPUProfiler::update()
     return snapshots[lastSnapshotIndex].time;
 }
 
+static void printSingleThreadInfo(
+    Thread *self, Thread *thread,
+    long long approxDt, long long newTime, long long oldTime, bool isIdleThread,
+    bool isNewThread)
+{
+    long long threadDt = newTime - oldTime;
+    long perc = (long)(threadDt >> 16) * 100 / approxDt;
+    iprintf("%p %10lld ns (%2ld.%1ld%%)", thread, threadDt, perc / 10, perc % 10);
+    if (isIdleThread) {
+        iprintf(" (idle)");
+        isIdleThread = false;
+    } else if (thread == self) {
+        iprintf(" (cur)");
+    }
+    if (isNewThread) {
+        iprintf(" new");
+    }
+    iprintf("\n");
+}
+
 void CPUProfiler::print()
 {
     Snapshot& oldSnap = snapshots[lastSnapshotIndex ^ 1];
@@ -198,28 +218,23 @@ void CPUProfiler::print()
             oldIt++;
         }
         // Found a thread that exists in both lists
-        long long threadDt = newIt->usedCpuTime - oldIt->usedCpuTime;
-        long perc = (long)(threadDt >> 16) * 100 / approxDt;
-        iprintf("%p %10lld ns (%2ld.%1ld%%)", newIt->thread, threadDt, perc / 10, perc % 10);
-        if (isIdleThread) {
-            iprintf(" (idle)\n");
-            isIdleThread = false;
-        } else if (newIt->thread == self) {
-            iprintf(" (cur)\n");
-        } else {
-            iprintf("\n");
-        }
+        printSingleThreadInfo(self, newIt->thread, approxDt, newIt->usedCpuTime,
+            oldIt->usedCpuTime, isIdleThread, false);
+        isIdleThread = false;
         newIt++;
         oldIt++;
     }
     // Skip last killed threads
     while (oldIt != oldInfo.end()) {
         iprintf("%p killed\n", oldIt->thread);
+        isIdleThread = false;
         oldIt++;
     }
-    // Skip newly created threads
+    // Print info about newly created threads
     while (newIt != newInfo.end()) {
-        iprintf("%p new\n", newIt->thread);
+        printSingleThreadInfo(self, newIt->thread, approxDt, newIt->usedCpuTime,
+            0, isIdleThread, true);
+        isIdleThread = false;
         newIt++;
     }
 }
@@ -265,11 +280,13 @@ void CPUProfiler::Snapshot::collect()
 void CPUProfiler::thread(long long nsInterval)
 {
     CPUProfiler profiler;
+    long long t = profiler.update();
     while (!Thread::testTerminate()) {
-        long long t = profiler.update();
+        t += nsInterval;
+        Thread::nanoSleepUntil(t);
+        profiler.update();
         profiler.print();
         iprintf("\n");
-        Thread::nanoSleepUntil(t + nsInterval);
     }
 }
 
diff --git a/miosix/util/util.h b/miosix/util/util.h
index 99c279737aebccc9b98f8163d852607a2bb7a62e..9b1e0349b199b3c5f5f869e11ffec611cb6a686f 100644
--- a/miosix/util/util.h
+++ b/miosix/util/util.h
@@ -123,11 +123,13 @@ void memDump(const void *start, int len);
  * and then invoking the update() and print() methods at regular intervals:
  * 
  *      CPUProfiler p;
+ *      long long t = p.update();
  *      while (...) {
- *          long long t = p.update();
+ *          t += 1000000000LL;
+ *          Thread::nanoSleepUntil(t);
+ *          p.update();
  *          p.print();
  *          ...
- *          Thread::nanoSleepUntil(t + 1000000000LL);
  *      }
  * 
  * The profiler will automatically keep track of the actual update period.