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
17package benchmarks.regression;
18
19import java.net.InetAddress;
20import java.net.UnknownHostException;
21
22public class DnsBenchmark {
23    public void timeDns(int reps) throws Exception {
24        String[] hosts = new String[] {
25            "www.amazon.com",
26            "z-ecx.images-amazon.com",
27            "g-ecx.images-amazon.com",
28            "ecx.images-amazon.com",
29            "ad.doubleclick.com",
30            "bpx.a9.com",
31            "d3dtik4dz1nej0.cloudfront.net",
32            "uac.advertising.com",
33            "servedby.advertising.com",
34            "view.atdmt.com",
35            "rmd.atdmt.com",
36            "spe.atdmt.com",
37            "www.google.com",
38            "www.cnn.com",
39            "bad.host.mtv.corp.google.com",
40        };
41        for (int i = 0; i < reps; ++i) {
42            try {
43                InetAddress.getByName(hosts[i % hosts.length]);
44            } catch (UnknownHostException ex) {
45            }
46        }
47    }
48}
49