Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Oct 2014 22:39:34 +0800
From:      "bycn82" <bycn82@gmail.com>
To:        <freebsd-ipfw@freebsd.org>
Subject:   performance of the swtich/case statements
Message-ID:  <009101cff386$29c30e50$7d492af0$@gmail.com>

next in thread | raw e-mail | index | archive | help
Hi All,

 

It is using the switch/case statement to make the code clear in the
implementation, so it reminded me the question which I want to ask when I
read the source of ipfw for the first time. It is about the performance of
the switch/case statement. Sure the code of this table feature are running
in the user-land, so there is no performance concern here, But my question
is the switch/case statements in the 2 loops.

 

I am not a C programmer, so I am not clear how the switch/case will be
optimized by the compiler in FreeBSD. But I used to write a compiler by
myself and I use a hash table to handle all the conditions in the case
statements because my compiler don't care about performance!, But in C it is
different, the case statement can only accept "int" values, so I don't think
it will use hash or what , it should be directly use an array(), So whether
it can be optimized it depends on the conditions in the switch/case
statements, and I noticed that the cases statement in the 2 loops are not
arranging the opcode in running number, so does the compiler smart enough to
optimize it?

 

Regards,

Bycn82

 

From: bycn82 [mailto:bycn82@gmail.com] 
Sent: Wednesday, 29 October, 2014 10:17 PM
To: 'freebsd-ipfw@freebsd.org'
Subject: ipfw table features

 

Hi,

Finally got some time to read the new implementation of table feature.
Compare to the previous code, it is much more clear now, Well done!

 

Regards,

Bycn82




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?009101cff386$29c30e50$7d492af0$>