You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: cpu.rs
    path of file: ./repos/tikv/components/resource_metering/src/recorder/sub_recorder
    
    the code of the file until where you have to start completion: // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.

use collections::HashMap;
use tikv_util::sys::thread::{self, Pid};

use crate::{
    metrics::STAT_TASK_COUNT,
    recorder::{
        localstorage::{LocalStorage, SharedTagInfos},
        SubRecorder,
    },
    RawRecords,
};

/// An implementation of [SubRecorder] for collecting cpu statistics.
///
/// `CpuRecorder` collects cpu usage at 
    
    fn test_record() {
        let info = Arc::new(TagInfos {
            store_id: 0,
            region_id: 0,
            peer_id: 0,
            key_ranges: vec![],
            extra_attachment: b"abc".to_vec(),
        });
        let store = LocalStorage {
            attached_tag: SharedTagInfos::new(info),
            ..Default::default()
        };
        let mut recorder = CpuRecorder::default();
        recorder.thread_created(thread::thread_id(), &store);
        let pid = thread::process_id();
        let tid = thread::thread_id();
        let prev_stat = &recorder.thread_stats.get(&tid).unwrap().stat;
        loop {
            let stat = thread::thread_stat(pid, tid).unwrap();
            let delta = stat.total_cpu_time() - prev_stat.total_cpu_time();
            if delta >= 0.001 {
                break;
            }
            heavy_job();
        }
        let mut records = RawRecords::default();
        recorder.tick(&mut records, &mut HashMap::default());
        assert!(!records.records.is_empty());
    }