I have the following code;
for ( int i = 0; i < 100 ; i++) {
for( int j = 0; j < 100 ; j++) {
System.out.println(j+"");
In this code I am gonna predict the branches by the method of one bit branch prediction. Let us say the first preference is "branch not taken". According to these, what is the branch prediction accuracy?
In this context, should I calculate the two loops seperately? I mean are there two different -one bit prediction scheme- for the two loop? If so, it this the correct way of calculating accuracy?
for second loop:
- taken (wrong prediction as first preference is branch not taken)
- taken (correct)
- taken (correct)
and when j = 99 taken (correct) and when j = 100 not taken (wrong prediction)
So there are 2 wrong prediction when j = 0 and 100 so accuracy is 99/101 for second loop? or should I calculate the loops together?