private static CpuAcctMetric parse ( final List < String > lines ) { // File has a header. We skip it // See src/test/resources/cpuacct.usage_all for an example final int ncpus = lines . size ( ) - 1 ; final long [ ] usrTime = new long [ ncpus ] ; final long [ ] sysTime = new long [ ncpus ] ; for ( int i = 1 ; i < lines . size ( ) ; i ++ ) { final String [ ] splits = lines . get ( i ) . split ( CgroupUtil . SPACE_MATCH , 3 ) ; if ( splits . length != 3 ) { throw new RE ( "Error parsing [%s]" , lines . get ( i ) ) ; } final int cpuNum = Integer . parseInt ( splits [ 0 ] ) ; usrTime [ cpuNum ] = Long . parseLong ( splits [ 1 ] ) ; sysTime [ cpuNum ] = Long . parseLong ( splits [ 2 ] ) ; } return new CpuAcctMetric ( usrTime , sysTime ) ; }
Private because it requires a specific format and cant take a generic list of strings