mardi 14 mars 2017

Number of Instructions in C code according to HIS code metrics

How many instructions are there in following function according to HIS code metrics?

  static uint16 CalcSignalBjbCurrents()
{
   uint16 u16Current;
   if(TRUE == bCurrValid)
   {
      if()
      {
         u16Current = 2;
      }
      else if()
      {
         u16Current = 1;
      }
      else
      {
         u16Current = 123;
      }
   }
   else
   {
      u16Current = 22;
   }

   return u16Current;
}

Details:

I can't find any difference between "Statement" and "Instruction" in C. I'll really appreciate if someone can answer it with valid reference.

I'm getting different values for number of instructions/statements when checking code metrics of this function using our internal SCA analyzer than when checking with SourceMonitor. My analysis of problem is that SourceMonitor is counting compound statements (like conditional tree) as multiple statements where our internal script is counting whole conditional tree as one instruction.

Our Script: Number of Instructions->8;

Source Monitor: Number of Stetments->11;

Aucun commentaire:

Enregistrer un commentaire