MCPcopy Create free account
hub / github.com/apache/nutch / benchmark

Method benchmark

src/java/org/apache/nutch/tools/Benchmark.java:179–267  ·  view source on GitHub ↗
(int seeds, int depth, int threads,
      int maxPerHost, long topN, String plugins)

Source from the content-addressed store, hash-verified

177 }
178
179 public BenchmarkResults benchmark(int seeds, int depth, int threads,
180 int maxPerHost, long topN, String plugins) throws Exception {
181 Configuration conf = getConf();
182 conf.set("http.proxy.host", "localhost");
183 conf.setInt("http.proxy.port", 8181);
184 conf.set("http.agent.name", "test");
185 conf.set("http.robots.agents", "test,*");
186 if (!plugins.equals("default")) {
187 conf.set("plugin.includes", plugins);
188 }
189 conf.setInt(GeneratorJob.GENERATOR_MAX_COUNT, maxPerHost);
190 conf.set(GeneratorJob.GENERATOR_COUNT_MODE,
191 GeneratorJob.GENERATOR_COUNT_VALUE_HOST);
192 Job job = NutchJob.getInstance(conf, "Benchmark");
193 FileSystem fs = FileSystem.get(job.getConfiguration());
194 Path dir = new Path(getConf().get("hadoop.tmp.dir"), "bench-"
195 + System.currentTimeMillis());
196 fs.mkdirs(dir);
197 Path rootUrlDir = new Path(dir, "seed");
198 fs.mkdirs(rootUrlDir);
199 createSeeds(fs, rootUrlDir, seeds);
200
201 if (LOG.isInfoEnabled()) {
202 LOG.info("crawl started in: " + dir);
203 LOG.info("rootUrlDir = " + rootUrlDir);
204 LOG.info("threads = " + threads);
205 LOG.info("depth = " + depth);
206 }
207
208 BenchmarkResults res = new BenchmarkResults();
209 res.depth = depth;
210 res.plugins = plugins;
211 res.seeds = seeds;
212 res.threads = threads;
213 res.topN = topN;
214
215 res.elapsed = System.currentTimeMillis();
216 InjectorJob injector = new InjectorJob(conf);
217 GeneratorJob generator = new GeneratorJob(conf);
218 FetcherJob fetcher = new FetcherJob(conf);
219 ParserJob parseBatch = new ParserJob(conf);
220 DbUpdaterJob crawlDbTool = new DbUpdaterJob(conf);
221 // not needed in the new API
222 // LinkDb linkDbTool = new LinkDb(getConf());
223
224 long start = System.currentTimeMillis();
225 // initialize crawlDb
226 injector.inject(rootUrlDir);
227 long delta = System.currentTimeMillis() - start;
228 res.addTiming("inject", "0", delta);
229 int i;
230 for (i = 0; i < depth; i++) { // generate new batch
231 start = System.currentTimeMillis();
232 String batchId = generator.generate(topN, System.currentTimeMillis(),
233 false, false, false);
234 delta = System.currentTimeMillis() - start;
235 res.addTiming("generate", i + "", delta);
236 if (batchId == null) {

Callers 1

runMethod · 0.95

Calls 15

getInstanceMethod · 0.95
createSeedsMethod · 0.95
injectMethod · 0.95
addTimingMethod · 0.95
generateMethod · 0.95
fetchMethod · 0.95
parseMethod · 0.95
runMethod · 0.95
processStatJobMethod · 0.95
getMethod · 0.65
getConfMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected