1821f49c1056d5918426ba365cc882352d3affe70Kenny Root/*
2821f49c1056d5918426ba365cc882352d3affe70Kenny Root * Copyright 2013 The Android Open Source Project
3821f49c1056d5918426ba365cc882352d3affe70Kenny Root *
4821f49c1056d5918426ba365cc882352d3affe70Kenny Root * Licensed under the Apache License, Version 2.0 (the "License");
5821f49c1056d5918426ba365cc882352d3affe70Kenny Root * you may not use this file except in compliance with the License.
6821f49c1056d5918426ba365cc882352d3affe70Kenny Root * You may obtain a copy of the License at
7821f49c1056d5918426ba365cc882352d3affe70Kenny Root *
8821f49c1056d5918426ba365cc882352d3affe70Kenny Root *      http://www.apache.org/licenses/LICENSE-2.0
9821f49c1056d5918426ba365cc882352d3affe70Kenny Root *
10821f49c1056d5918426ba365cc882352d3affe70Kenny Root * Unless required by applicable law or agreed to in writing, software
11821f49c1056d5918426ba365cc882352d3affe70Kenny Root * distributed under the License is distributed on an "AS IS" BASIS,
12821f49c1056d5918426ba365cc882352d3affe70Kenny Root * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13821f49c1056d5918426ba365cc882352d3affe70Kenny Root * See the License for the specific language governing permissions and
14821f49c1056d5918426ba365cc882352d3affe70Kenny Root * limitations under the License.
15821f49c1056d5918426ba365cc882352d3affe70Kenny Root */
16821f49c1056d5918426ba365cc882352d3affe70Kenny Root
17821f49c1056d5918426ba365cc882352d3affe70Kenny Rootpackage benchmarks.regression;
18821f49c1056d5918426ba365cc882352d3affe70Kenny Root
19821f49c1056d5918426ba365cc882352d3affe70Kenny Rootimport javax.net.ssl.SSLSocket;
20821f49c1056d5918426ba365cc882352d3affe70Kenny Rootimport libcore.java.security.TestKeyStore;
21821f49c1056d5918426ba365cc882352d3affe70Kenny Rootimport libcore.javax.net.ssl.TestSSLContext;
22821f49c1056d5918426ba365cc882352d3affe70Kenny Rootimport libcore.javax.net.ssl.TestSSLSocketPair;
23821f49c1056d5918426ba365cc882352d3affe70Kenny Root
24ea13f8291a92b6f47f50011da1d5e8c107984bc3Paul Duffinpublic class SSLLoopbackBenchmark {
25821f49c1056d5918426ba365cc882352d3affe70Kenny Root
26821f49c1056d5918426ba365cc882352d3affe70Kenny Root    public void time(int reps) throws Exception {
27821f49c1056d5918426ba365cc882352d3affe70Kenny Root        for (int i = 0; i < reps; ++i) {
28821f49c1056d5918426ba365cc882352d3affe70Kenny Root            TestSSLContext context = TestSSLContext.create(
292cca77af136c57106bd9a1652e54a0ee99154d89Alex Klyubin                    TestKeyStore.getClient(), TestKeyStore.getServer());
30821f49c1056d5918426ba365cc882352d3affe70Kenny Root            SSLSocket[] sockets = TestSSLSocketPair.connect(context, null, null);
31821f49c1056d5918426ba365cc882352d3affe70Kenny Root            context.close();
32821f49c1056d5918426ba365cc882352d3affe70Kenny Root            sockets[0].close();
33821f49c1056d5918426ba365cc882352d3affe70Kenny Root            sockets[1].close();
34821f49c1056d5918426ba365cc882352d3affe70Kenny Root        }
35821f49c1056d5918426ba365cc882352d3affe70Kenny Root    }
36821f49c1056d5918426ba365cc882352d3affe70Kenny Root}
37