Home | History | Annotate | Download | only in regression
      1 /*
      2  * Copyright (C) 2010 Google Inc.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  * http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package benchmarks.regression;
     18 
     19 import com.google.caliper.Param;
     20 import com.google.caliper.Runner;
     21 import com.google.caliper.SimpleBenchmark;
     22 
     23 public class IntConstantRemainderBenchmark extends SimpleBenchmark {
     24     public int timeRemainderIntByConstant2(int reps) {
     25         int result = 1;
     26         for (int i = 0; i < reps; ++i) {
     27             result %= 2;
     28         }
     29         return result;
     30     }
     31     public int timeRemainderIntByConstant8(int reps) {
     32         int result = 1;
     33         for (int i = 0; i < reps; ++i) {
     34             result %= 8;
     35         }
     36         return result;
     37     }
     38 /*
     39     public int timeRemainderIntByConstant10(int reps) {
     40         int result = 1;
     41         for (int i = 0; i < reps; ++i) {
     42             result %= 10;
     43         }
     44         return result;
     45     }
     46     public int timeRemainderIntByConstant100(int reps) {
     47         int result = 1;
     48         for (int i = 0; i < reps; ++i) {
     49             result %= 100;
     50         }
     51         return result;
     52     }
     53 */
     54     public int timeRemainderIntByConstant2048(int reps) {
     55         int result = 1;
     56         for (int i = 0; i < reps; ++i) {
     57             result %= 2048;
     58         }
     59         return result;
     60     }
     61     public int timeRemainderIntByVariable2(int reps) {
     62         int result = 1;
     63         int factor = 2;
     64         for (int i = 0; i < reps; ++i) {
     65             result %= factor;
     66         }
     67         return result;
     68     }
     69 /*
     70     public int timeRemainderIntByVariable10(int reps) {
     71         int result = 1;
     72         int factor = 10;
     73         for (int i = 0; i < reps; ++i) {
     74             result %= factor;
     75         }
     76         return result;
     77     }
     78 */
     79 }
     80