| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Bench |
|
| 1.5;1.5 |
| 1 | package org.crosswire.jsword.examples; | |
| 2 | /** | |
| 3 | * Distribution License: | |
| 4 | * JSword is free software; you can redistribute it and/or modify it under | |
| 5 | * the terms of the GNU Lesser General Public License, version 2.1 or later | |
| 6 | * as published by the Free Software Foundation. This program is distributed | |
| 7 | * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even | |
| 8 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 9 | * See the GNU Lesser General Public License for more details. | |
| 10 | * | |
| 11 | * The License is available on the internet at: | |
| 12 | * http://www.gnu.org/copyleft/lgpl.html | |
| 13 | * or by writing to: | |
| 14 | * Free Software Foundation, Inc. | |
| 15 | * 59 Temple Place - Suite 330 | |
| 16 | * Boston, MA 02111-1307, USA | |
| 17 | * | |
| 18 | * © CrossWire Bible Society, 2005 - 2016 | |
| 19 | * | |
| 20 | */ | |
| 21 | import java.util.List; | |
| 22 | ||
| 23 | import org.crosswire.jsword.book.Book; | |
| 24 | import org.crosswire.jsword.book.BookFilters; | |
| 25 | import org.crosswire.jsword.book.Books; | |
| 26 | ||
| 27 | /** | |
| 28 | * Bench is a command line utility that runs the Speed benchmark program. | |
| 29 | * | |
| 30 | * @see gnu.lgpl.License The GNU Lesser General Public License for details. | |
| 31 | * @author Joe Walker | |
| 32 | */ | |
| 33 | public final class Bench { | |
| 34 | 0 | private Bench() { |
| 35 | 0 | } |
| 36 | ||
| 37 | /** | |
| 38 | * Basic constructor | |
| 39 | * @param args | |
| 40 | */ | |
| 41 | public static void main(String[] args) { | |
| 42 | 0 | Book version = null; |
| 43 | ||
| 44 | 0 | if (args.length == 0) { |
| 45 | 0 | usage(); |
| 46 | 0 | versions(); |
| 47 | //System.exit(1); | |
| 48 | } | |
| 49 | ||
| 50 | 0 | List<Book> dicts = Books.installed().getBooks(BookFilters.getOnlyBibles()); |
| 51 | 0 | version = dicts.get(0); |
| 52 | ||
| 53 | 0 | Speed speed = new Speed(version); |
| 54 | 0 | speed.run(); |
| 55 | ||
| 56 | 0 | double time = speed.getBenchmark() / 1000.0; |
| 57 | 0 | System.out.println("CBench mark for '" + version + "': " + time + "s"); |
| 58 | 0 | } |
| 59 | ||
| 60 | /** | |
| 61 | * Print a usage message to stdout | |
| 62 | */ | |
| 63 | private static void usage() { | |
| 64 | 0 | System.out.println("Usage: CBench [<version>] [disk]"); |
| 65 | 0 | System.out.println(" where <version> is the name of a version to benchmark."); |
| 66 | 0 | System.out.println(" and 'disk' specifies if the Raw version should not cache data."); |
| 67 | 0 | System.out.println(" Remember to quote the version name if it includes spaces."); |
| 68 | 0 | } |
| 69 | ||
| 70 | /** | |
| 71 | * List the available versions | |
| 72 | */ | |
| 73 | private static void versions() { | |
| 74 | 0 | System.out.println(" Available versions:"); |
| 75 | 0 | List<Book> lbmds = Books.installed().getBooks(); |
| 76 | 0 | for (Book book : lbmds) { |
| 77 | 0 | System.out.println(" " + book.getName()); |
| 78 | } | |
| 79 | 0 | } |
| 80 | } |