当前位置: 首页>>代码示例>>Java>>正文


Java JSAPResult.getDouble方法代码示例

本文整理汇总了Java中com.martiansoftware.jsap.JSAPResult.getDouble方法的典型用法代码示例。如果您正苦于以下问题:Java JSAPResult.getDouble方法的具体用法?Java JSAPResult.getDouble怎么用?Java JSAPResult.getDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.martiansoftware.jsap.JSAPResult的用法示例。


在下文中一共展示了JSAPResult.getDouble方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(String[] args) throws IllegalArgumentException, JSAPException, IOException, ReflectiveOperationException {
	JsapResultsWithObject<TestMatrix> jsapResultsWithObject = 
			JsapUtils.constructObject(TestMatrix.class, args, 
			"Test a matrix, measuring its confusion matrix.",
			new Parameter[] {
				new UnflaggedOption( "n", 
						JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY,
						"Number of experiments." ),
				new UnflaggedOption( "numsample", 
						JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY,
						"Number of nodes in a sample." ),	
				new FlaggedOption("trunc", JSAP.INTEGER_PARSER,
						JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 't', "trunc",
						"If an int k is provided, it tests the matrix truncated to its "
						+ " k highest-absolute-valued elements. "),
				new FlaggedOption("lessrecallthan", JSAP.DOUBLE_PARSER,
						JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NO_SHORTFLAG, "lessrecallthan",
						"Show how many experiments showed a recall lower "
						+ "then then the provided value.")
			});
	
	TestMatrix t = jsapResultsWithObject.getObject();
	JSAPResult jsap = jsapResultsWithObject.getJsapResult();
	if (jsap.contains("trunc")) {
		int trunc = jsap.getInt("trunc");
		t.matrix.truncateTo(trunc);
	}
	ClassifierResults[] testResults = t.computeNExperiments(jsap.getInt("n"), jsap.getInt("numsample"));
	System.out.println("========= MEAN OF TEST RESULTS ========");
	System.out.println(ClassifierResults.avg(Arrays.asList(testResults)));
	
	if (jsap.contains("lessrecallthan")) {
		double threshold = jsap.getDouble("lessrecallthan");
		int nLower = 0;
		for (ClassifierResults test : testResults)
			if (test.getDouble(Stats.RECALL) < threshold)
				nLower++;
		System.out.println("Number of experiments with lower recall "
				+ "than " + threshold + ": "
				+ nLower + "/" + testResults.length 
				+ " (" + ((double) nLower / testResults.length * 100.0) + "%)"  );
	}
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:44,代码来源:TestMatrix.java

示例2: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(final String[] arg) throws JSAPException {

		final SimpleJSAP jsap = new SimpleJSAP(EliasFanoMonotoneLongBigListSpeedTest.class.getName(), "Tests the speed Elias-Fano monotone lists.",
				new Parameter[] {
					new UnflaggedOption("numElements", JSAP.INTSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The number of elements."),
					new UnflaggedOption("density", JSAP.DOUBLE_PARSER, ".5", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The density."),
					new FlaggedOption("numPos", JSAP.INTSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, 'p', "positions", "The number of positions to test"),
					new FlaggedOption("bulk", JSAP.INTSIZE_PARSER, "10", JSAP.NOT_REQUIRED, 'b', "bulk", "The number of positions to read with the bulk method"),
		});

		final JSAPResult jsapResult = jsap.parse(arg);
		if (jsap.messagePrinted()) return;

		final int numElements = jsapResult.getInt("numElements");
		final double density = jsapResult.getDouble("density");
		final int numPos = jsapResult.getInt("numPos");
		final int bulk = jsapResult.getInt("bulk");

		final RandomGenerator random = new XoRoShiRo128PlusRandomGenerator(42);
		final IntArrayList list = new IntArrayList(numElements);
		for(long i = numElements; i-- != 0;) list.add(random.nextDouble() < density ? 0 : 100);

		final int[] position = new int[numPos];

		for(int i = numPos; i-- != 0;) position[i] = (random.nextInt() & 0x7FFFFFFF) % (numElements - bulk);
		final long[] elements = new long[list.size()];
		elements[0] = list.getInt(0);
		for(int i = 1; i < list.size(); i++) elements[i] = list.getInt(i) + elements[i - 1];
		final EliasFanoMonotoneLongBigList eliasFanoMonotoneLongBigList = new EliasFanoMonotoneLongBigList(LongArrayList.wrap(elements));
		long time;
		System.err.println("getLong():");
		for(int k = 10; k-- != 0;) {
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) eliasFanoMonotoneLongBigList.getLong(position[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + time / (double)numPos + " ns/element");
		}

		final long[] dest = new long[bulk];
		System.err.println("get():");
		for(int k = 10; k-- != 0;) {
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) eliasFanoMonotoneLongBigList.get(position[i], dest);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + time / (double)(numPos * bulk) + " ns/element");
		}
	}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:48,代码来源:EliasFanoMonotoneLongBigListSpeedTest.java

示例3: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(final String[] arg) throws JSAPException {

		final SimpleJSAP jsap = new SimpleJSAP(SelectSpeedTest.class.getName(), "Tests the speed of rank/select implementations.",
				new Parameter[] {
					new UnflaggedOption("numBits", JSAP.LONGSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The number of bits."),
					new UnflaggedOption("density", JSAP.DOUBLE_PARSER, ".5", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The density."),
					new FlaggedOption("numPos", JSAP.INTSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, 'p', "positions", "The number of positions to test"),
					//new FlaggedOption("encoding", ForNameStringParser.getParser(Charset.class), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term file encoding."),
					//new Switch("zipped", 'z', "zipped", "The term list is compressed in gzip format."),
					//new FlaggedOption("termFile", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'o', "offline", "Read terms from this file (without loading them into core memory) instead of standard input."),
					//new UnflaggedOption("trie", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised hollow trie.")
		});

		final JSAPResult jsapResult = jsap.parse(arg);
		if (jsap.messagePrinted()) return;

		final long numBits = jsapResult.getLong("numBits");
		final double density = jsapResult.getDouble("density");
		final int numPos = jsapResult.getInt("numPos");

		final RandomGenerator random = new XoRoShiRo128PlusRandomGenerator(42);
		final LongArrayBitVector bitVector = LongArrayBitVector.getInstance().length(numBits);
		long c = 0;
		for(long i = numBits; i-- != 0;)
			if (random.nextDouble() < density) {
				bitVector.set(i);
				c++;
			}

		final long[] rankPosition = new long[numPos];
		final long[] selectPosition = new long[numPos];

		for(int i = numPos; i-- != 0;) {
			rankPosition[i] = (random.nextLong() & 0x7FFFFFFFFFFFFFFFL) % numBits;
			selectPosition[i] = (random.nextLong() & 0x7FFFFFFFFFFFFFFFL) % c;
		}

		long time;
		final SimpleSelect simpleSelect = new SimpleSelect(bitVector);
		for(int k = 1000; k-- != 0;) {

			System.out.println("=== Simple ===");
			time = - System.currentTimeMillis();
			for(int i = 0; i < numPos; i++) simpleSelect.select(selectPosition[i]);
			time += System.currentTimeMillis();
			System.err.println(time / 1000.0 + "s, " + (time * 1E6) / numPos + " ns/select");

/*			System.out.println("=== Sparse ===");
			SparseSelect sparseSelect = new SparseSelect(bitVector);
			time = - System.currentTimeMillis();
			for(int i = 0; i < numPos; i++) sparseSelect.select(selectPosition[i]);
			time += System.currentTimeMillis();
	 		System.err.println(time / 1000.0 + "s, " + (time * 1E6) / numPos + " ns/select");*/
		}
	}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:56,代码来源:SelectSpeedTest.java

示例4: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(final String[] arg) throws JSAPException {

		final SimpleJSAP jsap = new SimpleJSAP(RankSpeedTest.class.getName(), "Tests the speed of rank/select implementations.",
				new Parameter[] {
					new UnflaggedOption("numBits", JSAP.LONGSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The number of bits."),
					new UnflaggedOption("density", JSAP.DOUBLE_PARSER, ".5", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The density."),
					new FlaggedOption("numPos", JSAP.INTSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, 'p', "positions", "The number of positions to test"),
					//new FlaggedOption("encoding", ForNameStringParser.getParser(Charset.class), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term file encoding."),
					//new Switch("zipped", 'z', "zipped", "The term list is compressed in gzip format."),
					//new FlaggedOption("termFile", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'o', "offline", "Read terms from this file (without loading them into core memory) instead of standard input."),
					//new UnflaggedOption("trie", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised hollow trie.")
		});

		final JSAPResult jsapResult = jsap.parse(arg);
		if (jsap.messagePrinted()) return;

		final long numBits = jsapResult.getLong("numBits");
		final double density = jsapResult.getDouble("density");
		final int numPos = jsapResult.getInt("numPos");

		final RandomGenerator random = new XoRoShiRo128PlusRandomGenerator(42);
		final LongArrayBitVector bitVector = LongArrayBitVector.getInstance().length(numBits);
		for(long i = numBits; i-- != 0;) if (random.nextDouble() < density) bitVector.set(i);

		final long[] rankPosition = new long[numPos];

		for(int i = numPos; i-- != 0;) rankPosition[i] = (random.nextLong() & 0x7FFFFFFFFFFFFFFFL) % numBits;

		long time;
		for(int k = 10; k-- != 0;) {
			System.out.println("=== Rank 9 ===");
			final Rank9 rank9 = new Rank9(bitVector);
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) rank9.rank(rankPosition[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + time / (double)numPos + " ns/rank (" + 100.0 * rank9.numBits() / numBits + "%)");

			System.out.println("=== Rank 9b ===");
			final Rank9GogPetri rank9b = new Rank9GogPetri(bitVector);
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) rank9b.rank(rankPosition[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + time / (double)numPos + " ns/rank (" + 100.0 * rank9b.numBits() / numBits + "%)");

			System.out.println("=== Rank 16 ===");
			final Rank16 rank16 = new Rank16(bitVector);
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) rank16.rank(rankPosition[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + time / (double)numPos + " ns/rank (" + 100.0 * rank16.numBits() / numBits + "%)");

			System.out.println("=== Rank 11 ===");
			final Rank11Original rank11 = new Rank11Original(bitVector);
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) rank11.rank(rankPosition[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + time / (double)numPos + " ns/rank (" + 100.0 * rank11.numBits() / numBits + "%)");

			System.out.println("=== Rank 11b ===");
			final Rank11 rank11b = new Rank11(bitVector);
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) rank11b.rank(rankPosition[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + time / (double)numPos + " ns/rank (" + 100.0 * rank11b.numBits() / numBits + "%)");

			System.out.println("=== Rank 12 ===");
			final Rank12 rank12 = new Rank12(bitVector);
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) rank12.rank(rankPosition[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + time / (double)numPos + " ns/rank (" + 100.0 * rank12.numBits() / numBits + "%)");
		}
	}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:74,代码来源:RankSpeedTest.java

示例5: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(final String[] arg) throws JSAPException {

		final SimpleJSAP jsap = new SimpleJSAP(TwoSizesLongBigListSpeedTest.class.getName(), "Tests the speed of rank/select implementations.",
				new Parameter[] {
					new UnflaggedOption("numElements", JSAP.INTSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The number of elements."),
					new UnflaggedOption("density", JSAP.DOUBLE_PARSER, ".5", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The density."),
					new FlaggedOption("numPos", JSAP.INTSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, 'p', "positions", "The number of positions to test"),
		});

		final JSAPResult jsapResult = jsap.parse(arg);
		if (jsap.messagePrinted()) return;

		final int numElements = jsapResult.getInt("numElements");
		final double density = jsapResult.getDouble("density");
		final int numPos = jsapResult.getInt("numPos");

		final XoRoShiRo128PlusRandomGenerator random = new XoRoShiRo128PlusRandomGenerator(0);
		final LongArrayList list = new LongArrayList(numElements);
		for(long i = numElements; i-- != 0;) list.add(random.nextDouble() < density ? 0 : 100);

		final int[] position = new int[numPos];

		for(int i = numPos; i-- != 0;) position[i] = (random.nextInt() & 0x7FFFFFFF) % numElements;
		final TwoSizesLongBigList twoSizes = new TwoSizesLongBigList(list);
		final EliasFanoLongBigList eliasFano = new EliasFanoLongBigList(list);
		final EliasFanoPrefixSumLongBigList eliasFanoPrefixSum = new EliasFanoPrefixSumLongBigList(list);
		final long[] elements = list.elements();
		for(int i = 1; i < list.size(); i++) elements[i] += elements[i - 1];
		final EliasFanoMonotoneLongBigList monotone = new EliasFanoMonotoneLongBigList(list);
		final EliasFanoMonotoneLongBigListTables tables = new EliasFanoMonotoneLongBigListTables(list);

		long time;

		for(int k = 10; k-- != 0;) {
			System.out.println("=== LongArrayList === (" + list.size() * (long)Long.SIZE + " bits)");
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) list.getLong(position[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + (double)time / numPos + " ns/get");

			System.out.println("=== TwoSizesLongBigList === (" + twoSizes.numBits() + " bits)");
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) twoSizes.getLong(position[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + (double)time / numPos + " ns/get");

			System.out.println("=== EliasFanoPrefixSumLongBigList === (" + eliasFanoPrefixSum.numBits() + " bits)");
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) eliasFanoPrefixSum.getLong(position[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + (double)time / numPos + " ns/get");

			System.out.println("=== EliasFanoLongBigList === (" + eliasFano.numBits() + " bits)");
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) eliasFano.getLong(position[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + (double)time / numPos + " ns/get");

			System.out.println("=== EliasFanoMonotoneLongBigListTables === (" + tables.numBits() + " bits)");
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) tables.getLong(position[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + (double)time / numPos + " ns/get");

			System.out.println("=== EliasFanoMonotoneLongBigList === (" + monotone.numBits() + " bits)");
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) monotone.getLong(position[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + (double)time / numPos + " ns/get");
		}
	}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:72,代码来源:TwoSizesLongBigListSpeedTest.java

示例6: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(final String[] arg) throws JSAPException {

		final SimpleJSAP jsap = new SimpleJSAP(RankSelectSpeedTest.class.getName(), "Tests the speed of rank/select implementations.",
				new Parameter[] {
					new UnflaggedOption("numBits", JSAP.LONGSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The number of bits."),
					new UnflaggedOption("density", JSAP.DOUBLE_PARSER, ".5", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The density."),
					new FlaggedOption("numPos", JSAP.INTSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, 'p', "positions", "The number of positions to test"),
		});

		final JSAPResult jsapResult = jsap.parse(arg);
		if (jsap.messagePrinted()) return;

		final long numBits = jsapResult.getLong("numBits");
		final double density = jsapResult.getDouble("density");
		final int numPos = jsapResult.getInt("numPos");

		final RandomGenerator random = new XoRoShiRo128PlusRandomGenerator(42);
		final LongArrayBitVector bitVector = LongArrayBitVector.getInstance().length(numBits);
		long c = 0;
		for(long i = numBits; i-- != 0;)
			if (random.nextDouble() < density) {
				bitVector.set(i);
				c++;
			}

		final long[] rankPosition = new long[numPos];
		final long[] selectPosition = new long[numPos];

		for(int i = numPos; i-- != 0;) {
			rankPosition[i] = (random.nextLong() & 0x7FFFFFFFFFFFFFFFL) % numBits;
			selectPosition[i] = (random.nextLong() & 0x7FFFFFFFFFFFFFFFL) % c;
		}

		long time;
		for(int k = 10; k-- != 0;) {
			System.out.println("=== Rank 9 ===");
			final Rank9 rank9 = new Rank9(bitVector);
			time = - System.currentTimeMillis();
			for(int i = 0; i < numPos; i++) rank9.rank(rankPosition[i]);
			time += System.currentTimeMillis();
			System.err.println(time / 1000.0 + "s, " + (time * 1E6) / numPos + " ns/rank");

			System.out.println("=== Rank 16 ===");
			final Rank16 rank16 = new Rank16(bitVector);
			time = - System.currentTimeMillis();
			for(int i = 0; i < numPos; i++) rank16.rank(rankPosition[i]);
			time += System.currentTimeMillis();
			System.err.println(time / 1000.0 + "s, " + (time * 1E6) / numPos + " ns/rank");

			System.out.println("=== Hinted bsearch ===");
			final HintedBsearchSelect hintedBsearchSelect = new HintedBsearchSelect(rank9);
			time = - System.currentTimeMillis();
			for(int i = 0; i < numPos; i++) hintedBsearchSelect.select(selectPosition[i]);
			time += System.currentTimeMillis();
			System.err.println(time / 1000.0 + "s, " + (time * 1E6) / numPos + " ns/select");

			System.out.println("=== Select9 ===");
			final Select9 select9 = new Select9(rank9);
			time = - System.currentTimeMillis();
			for(int i = 0; i < numPos; i++) select9.select(selectPosition[i]);
			time += System.currentTimeMillis();
			System.err.println(time / 1000.0 + "s, " + (time * 1E6) / numPos + " ns/select");

			System.out.println("=== Simple ===");
			final SimpleSelect simpleSelect = new SimpleSelect(bitVector);
			time = - System.currentTimeMillis();
			for(int i = 0; i < numPos; i++) simpleSelect.select(selectPosition[i]);
			time += System.currentTimeMillis();
			System.err.println(time / 1000.0 + "s, " + (time * 1E6) / numPos + " ns/select");

			System.out.println("=== Sparse ===");
			final SparseSelect sparseSelect = new SparseSelect(bitVector);
			time = - System.currentTimeMillis();
			for(int i = 0; i < numPos; i++) sparseSelect.select(selectPosition[i]);
			time += System.currentTimeMillis();
			System.err.println(time / 1000.0 + "s, " + (time * 1E6) / numPos + " ns/select");
		}
	}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:79,代码来源:RankSelectSpeedTest.java

示例7: main

import com.martiansoftware.jsap.JSAPResult; //导入方法依赖的package包/类
public static void main(final String[] arg) throws JSAPException {

		final SimpleJSAP jsap = new SimpleJSAP(EliasFanoLongBigListSpeedTest.class.getName(), "Tests the speed of Elias-Fano compressed lists.",
				new Parameter[] {
					new UnflaggedOption("numElements", JSAP.INTSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The number of elements."),
					new UnflaggedOption("density", JSAP.DOUBLE_PARSER, ".5", JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "The density."),
					new FlaggedOption("numPos", JSAP.INTSIZE_PARSER, "1Mi", JSAP.NOT_REQUIRED, 'p', "positions", "The number of positions to test"),
					new FlaggedOption("bulk", JSAP.INTSIZE_PARSER, "10", JSAP.NOT_REQUIRED, 'b', "bulk", "The number of positions to read with the bulk method"),
		});

		final JSAPResult jsapResult = jsap.parse(arg);
		if (jsap.messagePrinted()) return;

		final int numElements = jsapResult.getInt("numElements");
		final double density = jsapResult.getDouble("density");
		final int numPos = jsapResult.getInt("numPos");
		final int bulk = jsapResult.getInt("bulk");

		final RandomGenerator random = new XoRoShiRo128PlusRandomGenerator(42);
		final IntArrayList list = new IntArrayList(numElements);
		for(long i = numElements; i-- != 0;) list.add(random.nextDouble() < density ? 0 : 100);

		final int[] position = new int[numPos];

		for(int i = numPos; i-- != 0;) position[i] = (random.nextInt() & 0x7FFFFFFF) % (numElements - bulk);
		final long[] elements = new long[list.size()];
		elements[0] = list.getInt(0);
		for(int i = 1; i < list.size(); i++) elements[i] = list.getInt(i) + elements[i - 1];
		final EliasFanoLongBigList eliasFanoLongBigList = new EliasFanoLongBigList(LongArrayList.wrap(elements));
		long time;
		System.err.println("getLong():");
		for(int k = 10; k-- != 0;) {
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) eliasFanoLongBigList.getLong(position[i]);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + time / (double)numPos + " ns/element");
		}

		final long[] dest = new long[bulk];
		System.err.println("get():");
		for(int k = 10; k-- != 0;) {
			time = - System.nanoTime();
			for(int i = 0; i < numPos; i++) eliasFanoLongBigList.get(position[i], dest);
			time += System.nanoTime();
			System.err.println(time / 1E9 + "s, " + time / (double)(numPos * bulk) + " ns/element");
		}
	}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:48,代码来源:EliasFanoLongBigListSpeedTest.java


注:本文中的com.martiansoftware.jsap.JSAPResult.getDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。