<commit_before>/*
 * Copyright (c) 2012-2013 by <NAME>, Zuse Institute Berlin
 *
 *
 * Licensed under the BSD License, see LICENSE file for details.
 *
 */

package org.xtreemfs.sandbox.benchmark;

import java.io.IOException;
import java.util.Random;

import org.xtreemfs.common.libxtreemfs.FileHandle;
import org.xtreemfs.common.libxtreemfs.Volume;
import org.xtreemfs.pbrpc.generatedinterfaces.GlobalTypes;

/**
 * Class implementing a filebased read benchmark.
 * 
 * @author jensvfischer
 */
class FilebasedReadBenchmark extends FilebasedBenchmark {

    private String[] filenames;

    FilebasedReadBenchmark(Volume volume, Config config) throws Exception {
        super(volume, config);
    }

    @Override
    void prepareBenchmark() throws Exception {
        this.filenames = VolumeManager.getInstance().getRandomFilelistForVolume(volume);
    }

    /* Called within the benchmark method. Performs the actual reading of data from the volume. */
    @Override
    long performIO(byte[] data, long numberOfBlocks) throws IOException {

        // long numberOfFilesToRead = convertTo4KiBBlocks(numberOfBlocks);
        long numberOfFilesToRead = config.randomSizeInBytes / 4096;

        int filenamesSize = filenames.length;
        long byteCounter = 0;
        Random random = new Random();

        int flags = GlobalTypes.SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDONLY.getNumber();

        for (long i = 0; i < numberOfFilesToRead; i++) {
            String filename = filenames[random.nextInt(filenamesSize)];
            FileHandle fileHandle = volume.openFile(config.userCredentials, filename, flags);
            byteCounter += fileHandle.read(config.userCredentials, data, randomIOFilesize, 0);
            fileHandle.close();
        }
        return byteCounter;
    }

    @Override
    void finalizeBenchmark() throws Exception {
    }

    long nextLong(long limit) {
        long next = Math.round(Math.random() * limit);
        assert next >= 0 : "Next long < 0";
        return next;
    }

}<commit_msg>server: benchmark: Delete unused nextLong method<commit_after>/*
 * Copyright (c) 2012-2013 by <NAME>, Zuse Institute Berlin
 *
 *
 * Licensed under the BSD License, see LICENSE file for details.
 *
 */

package org.xtreemfs.sandbox.benchmark;

import java.io.IOException;
import java.util.Random;

import org.xtreemfs.common.libxtreemfs.FileHandle;
import org.xtreemfs.common.libxtreemfs.Volume;
import org.xtreemfs.pbrpc.generatedinterfaces.GlobalTypes;

/**
 * Class implementing a filebased read benchmark.
 * 
 * @author jensvfischer
 */
class FilebasedReadBenchmark extends FilebasedBenchmark {

    private String[] filenames;

    FilebasedReadBenchmark(Volume volume, Config config) throws Exception {
        super(volume, config);
    }

    @Override
    void prepareBenchmark() throws Exception {
        this.filenames = VolumeManager.getInstance().getRandomFilelistForVolume(volume);
    }

    /* Called within the benchmark method. Performs the actual reading of data from the volume. */
    @Override
    long performIO(byte[] data, long numberOfBlocks) throws IOException {

        // long numberOfFilesToRead = convertTo4KiBBlocks(numberOfBlocks);
        long numberOfFilesToRead = config.randomSizeInBytes / 4096;

        int filenamesSize = filenames.length;
        long byteCounter = 0;
        Random random = new Random();

        int flags = GlobalTypes.SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDONLY.getNumber();

        for (long i = 0; i < numberOfFilesToRead; i++) {
            String filename = filenames[random.nextInt(filenamesSize)];
            FileHandle fileHandle = volume.openFile(config.userCredentials, filename, flags);
            byteCounter += fileHandle.read(config.userCredentials, data, randomIOFilesize, 0);
            fileHandle.close();
        }
        return byteCounter;
    }

    @Override
    void finalizeBenchmark() throws Exception {
    }

}
{'fraction_non_alphanumeric': 0.09125571936959838, 'fraction_numerical': 0.00864260294865277, 'mean_word_length': 3.272529858849077, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '535709', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1120, 'n_words': 282}