纵有疾风起
人生不言弃

帮做Java程序、Java代做、代做Java语言、Java代做

import java.io.*;import java.util.*;/**** @author skonlc brinkmwj and karroje and krumpenj* @Date : 2009-10-04, 2011-03-10, 2015-09-27, 2017-04-22 Sources : All code is* original Purpose : The purpose of this file is to do some VERY* rudimentary timing of your increaseCount method. For the QUALITY* measures I am also going to test getCount and getNthMostPopular, so you* might want to design some way to test out the running time of your* getCount as well.*/public class Controller {/** The only purpose of main() is to call processFile with increasingingly* larger and larger files. A larger file will give a more accurate sense of* how fast addToTrends is, but at some point it may take so long to do the* getNthMostPopular, that we arent willing to wait for it to finish.*/static Random rng;public static void main(String[] args) {/** These files are books from project Gutenberg. I have provided the* inputs, as well as my outputs in the starter files*//** NOTE: You may want to comment some of these out! Unless your program* is very speedy on all operations some of these will never finish.*/rng = new Random(42);timeTests(&”1.txt&”);// processFile(&”2.txt&”);// processFile(&”3.txt&”);// processFile(&”4.txt&”);// processFile(&”5.txt&”);// processFile(&”6.txt&”);// processFile(&”7.txt&”);}public static ArrayList readFile(String fileName) {ArrayList wordList = new ArrayList wordList = readFile(file);// Aver帮做Java程序、Java作业代做留学生、代做留学生Java语言、Java实验代做age time for insertlong startTime = System.nanoTime();LookupInterface tr = new StudentLookup();for (String w : wordList)tr.addString(1, w);long endTime = System.nanoTime();double test1 = (double) ((endTime – startTime) / 1000000.0) / (double) wordList.size();System.out.println(&”Test 1: &” + test1 + &” milliseconds / insert&”);// Average time for getCountstartTime = System.nanoTime();for (String w : wordList)tr.lookupCount(w);endTime = System.nanoTime();double test2 = (double) ((endTime – startTime) / 1000000.0) / (double) wordList.size();System.out.println(&”Test 2: &” + test2 + &” milliseconds / getCount&”);// Average time for getNthMostPopular();int n = tr.numEntries();startTime = System.nanoTime();for (int i = 0; i tr.lookupPopularity(i);endTime = System.nanoTime();double test3 = (double) ((endTime – startTime) / 1000000.0) / (double) n;System.out.println(&”Test 3: &” + test3 + &” milliseconds / getNthMostPopular&”);// Average time per operation when mixing operationstr = new StudentLookup();startTime = System.nanoTime();n = 0;for (int i = 0; i tr.addString(1, wordList.get(i));if (rng.nextDouble() n = tr.numEntries();if (rng.nextDouble() tr.lookupPopularity(rng.nextInt(Math.max(n, 1)));}}endTime = System.nanoTime();double test4 = (endTime – startTime) / 1000000000.0;System.out.println(&”Test 4: &” + test4 + &” seconds (total)&”);}}& 转自:http://ass.3daixie.com/2018061815675058.html

文章转载于:https://www.jianshu.com/p/b5fdb03b4197

原著是一个有趣的人,若有侵权,请通知删除

未经允许不得转载:起风网 » 帮做Java程序、Java代做、代做Java语言、Java代做
分享到: 生成海报

评论 抢沙发

评论前必须登录!

立即登录