Mark Gritter (markgritter) wrote,
Mark Gritter
markgritter

Mini-WTF

Encountered today:

if ( stats.readOps > 0 ) {
    averageReadLatency = stats.readLatency / stats.readOps;
}

if ( stats.writeOps > 0 ) {
    averageWriteLatency = stats.writeLatency / stats.writeOps;
}

systemStats.averageLatency = 0;
if ( ( stats.readOps + stats.writeOps) > 0) {
    systemStats.averageLatency = 
        ( ( averageReadLatency * stats.readOps) + 
          ( averageWriteLatency * stats.writeOps) ) / 
        ( stats.readOps + stats.writeOps);
}

return systemStats;


I don't think that the effects of integer rounding were a desired side effect here. So we can probably safely assume that a / b * b = a.
Tags: code, programming
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 16 comments