The StorageBackendException is catched two times so that the user see the "500 internal server error" only at the second catch (probably fixes #5).
2 * StarOffice News Server
3 * see AUTHORS for the list of contributors
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 import java.util.ArrayList;
22 import java.util.LinkedList;
23 import java.util.List;
24 import java.util.ListIterator;
27 * Tests the speed of LinkedList and ArrayList.
28 * @author Christian Lins
31 public class CollectionsSpeedTest
34 public static void main(String[] args)
36 List arrayList = new ArrayList();
37 List linkedList = new LinkedList();
39 int numElements = 100000;
41 System.out.println("ArrayList.add(): " + add(arrayList, numElements) + "ms");
42 System.out.println("LinkenList.add(): " + add(linkedList, numElements) + "ms");
43 System.out.println("ArrayList.iterate: " + iterate(arrayList) + "ms");
44 System.out.println("LinkedList.iterate: " + iterate(linkedList) + "ms");
47 private static long add(List list, int numElements)
49 long start = System.currentTimeMillis();
51 for(int n = 0; n < numElements; n++)
53 list.add(new Object());
56 return System.currentTimeMillis() - start;
59 private static long iterate(List list)
61 long start = System.currentTimeMillis();
63 ListIterator iter = list.listIterator();
69 return System.currentTimeMillis() - start;