コード例 #1
0
ファイル: tdriver-deliver.cpp プロジェクト: Kangmo/infinidb
//------------------------------------------------------------------------------
// Perform testcases for a 1 column table, a 2 column table, etc, up to
// a table having "maxCols" columns.
//------------------------------------------------------------------------------
void testSizes()   
{

	// Prompt for schema.
	cout << "Enter Schema or Enter for " << schema << ":  ";
	string tmpSchema;
	getline(cin, tmpSchema);
	if(tmpSchema.length() > 0)
	{
		schema = tmpSchema;
	}

	// Prompt for table.
	cout << "Enter Table or Enter for " << colstable << ":  ";
	string tmpTable;
	getline(cin, tmpTable);
	if(tmpTable.length() > 0)
	{
		colstable = tmpTable;
	}

	timer.start("Total");
	int maxCols = 9;
	cout << endl;
	for(int i = 7; i <= maxCols; i++) {
		cout << endl << "Running test " << i << " of " << maxCols << endl;
		stringstream ss;
		ss << "Delivery test for " << dataSize << " rows and " << i << " columns";
		timer.start(ss.str());
		deliverTest(i);
		timer.stop(ss.str());
	}
	timer.stop("Total");
	timer.finish();
}
コード例 #2
0
void
EventDeliveryManager::gather_events( bool done )
{
  // IMPORTANT: Ensure that gather_events(..) is called from a single thread and
  //            NOT from a parallel OpenMP region!!!

  // Stop watch for time measurements within this function
  static Stopwatch stw_local;

  stw_local.reset();
  stw_local.start();
  collocate_buffers_( done );
  stw_local.stop();
  time_collocate_ += stw_local.elapsed();
  stw_local.reset();
  stw_local.start();
  if ( off_grid_spiking_ )
  {
    kernel().mpi_manager.communicate(
      local_offgrid_spikes_, global_offgrid_spikes_, displacements_ );
  }
  else
  {
    kernel().mpi_manager.communicate(
      local_grid_spikes_, global_grid_spikes_, displacements_ );
  }
  stw_local.stop();
  time_communicate_ += stw_local.elapsed();
}
コード例 #3
0
ADD_TEST(StopWatchTest, TestAll) {
	
	Stopwatch sw;
	sw.start();
	this_thread::sleep_for(chrono::milliseconds(200));
	sw.stop();
	Int64 d = sw.elapsed();
	CHECK(d > 180000);
	CHECK(d < 300000);

	sw.start();
	this_thread::sleep_for(chrono::milliseconds(100));
	sw.stop();
	d = sw.elapsed();
	CHECK(d > 280000);
	CHECK(d < 400000);
	
	this_thread::sleep_for(chrono::milliseconds(100));
	sw.stop();
	d = sw.elapsed();
	CHECK(d > 380000);
	CHECK(d < 500000);
	
	sw.restart();
	sw.start();
	this_thread::sleep_for(chrono::milliseconds(200));
	sw.stop();
	d = sw.elapsed();
	CHECK(d > 180000);
	CHECK(d < 300000);
}
コード例 #4
0
ファイル: tdriver-zdl.cpp プロジェクト: Kangmo/infinidb
	//--------------------------------------------------------------------------
	// ZDL benchmark functions
	//--------------------------------------------------------------------------
 	void ZDL_bench_1set_seq()
	{
		typedef ElementType Element;

		uint i;
		uint numOfProducers = NUM_PRODUCERS;
		uint numOfConsumers = NUM_CONSUMERS;
		ZDL<Element> zdl(numOfConsumers, fRm);
	    zdl.setMultipleProducers(true);		
		zdl.setElementMode(1); // RID_VALUE
		pthread_t producer[numOfProducers];
		pthread_t consumer[numOfConsumers];
		ThreadParms producerThreadParms[NUM_PRODUCERS];
		ThreadParms consumerThreadParms[NUM_CONSUMERS];
		struct timespec ts1, ts2, diff;
        
        timer.start("zdl-produce_1set_seq");
		clock_gettime(CLOCK_REALTIME, &ts1);
		for (i = 0; i < numOfProducers; i++)
		{
			producerThreadParms[i].zdl          = &zdl;
			producerThreadParms[i].threadNumber = i;
            producerThreadParms[i].count        = ::count1Set;
		    pthread_create(&producer[i], NULL,
				ZDL_producer_1set_seq<Element>, &producerThreadParms[i]);
		}
		for (i = 0; i < numOfProducers; i++)
		    pthread_join(producer[i], NULL);
		zdl.endOfInput();
		timer.stop("zdl-produce_1set_seq");
		
		timer.start("zdl-consume_1set_seq");
		for (i = 0; i < numOfConsumers; i++)
		{
			consumerThreadParms[i].zdl          = &zdl;
			consumerThreadParms[i].threadNumber = i;
            consumerThreadParms[i].count        = 0;
		    pthread_create(&consumer[i], NULL,
				ZDL_consumer<Element>, &consumerThreadParms[i]);
		}
		for (i = 0; i < numOfConsumers; i++)
		    pthread_join(consumer[i], NULL);   
		clock_gettime(CLOCK_REALTIME, &ts2);
        timer.stop("zdl-consume_1set_seq");	

        timer.finish();	
		timespec_sub(ts1, ts2, diff);
        cout << "# of Producers: " << numOfProducers << endl;
        cout << "# of Consumers: " << numOfConsumers << endl;
		cout << "ZDL_bench_1set_seq: producer & consumer passed " << 
			zdl.totalSize() << " elements in " << diff.tv_sec << "s " <<
			diff.tv_nsec << "ns" << endl;

		ZDL_printFileStats<Element>(&zdl);
		validateResults(::count1Set*NUM_PRODUCERS);
	}
コード例 #5
0
ファイル: zlib_buffers.cpp プロジェクト: shenqsdev/ClickHouse
int main(int, char **)
try
{
    std::cout << std::fixed << std::setprecision(2);

    size_t n = 100000000;
    Stopwatch stopwatch;

    {
        DB::WriteBufferFromFile buf("test_zlib_buffers.gz", DBMS_DEFAULT_BUFFER_SIZE, O_WRONLY | O_CREAT | O_TRUNC);
        DB::ZlibDeflatingWriteBuffer deflating_buf(buf, DB::CompressionMethod::Gzip, /* compression_level = */ 3);

        stopwatch.restart();
        for (size_t i = 0; i < n; ++i)
        {
            DB::writeIntText(i, deflating_buf);
            DB::writeChar('\t', deflating_buf);
        }
        deflating_buf.finish();

        stopwatch.stop();
        std::cout << "Writing done. Elapsed: " << stopwatch.elapsedSeconds() << " s."
            << ", " << (deflating_buf.count() / stopwatch.elapsedSeconds() / 1000000) << " MB/s"
            << std::endl;
    }

    {
        DB::ReadBufferFromFile buf("test_zlib_buffers.gz");
        DB::ZlibInflatingReadBuffer inflating_buf(buf, DB::CompressionMethod::Gzip);

        stopwatch.restart();
        for (size_t i = 0; i < n; ++i)
        {
            size_t x;
            DB::readIntText(x, inflating_buf);
            inflating_buf.ignore();

            if (x != i)
                throw DB::Exception("Failed!, read: " + std::to_string(x) + ", expected: " + std::to_string(i), 0);
        }
        stopwatch.stop();
        std::cout << "Reading done. Elapsed: " << stopwatch.elapsedSeconds() << " s."
            << ", " << (inflating_buf.count() / stopwatch.elapsedSeconds() / 1000000) << " MB/s"
            << std::endl;
    }

    return 0;
}
catch (const DB::Exception & e)
{
    std::cerr << e.what() << ", " << e.displayText() << std::endl;
    return 1;
}
コード例 #6
0
    static void NO_INLINE execute(const Source & data, size_t num_threads,
                        Creator && creator, Updater && updater, Merger && merger,
                        ThreadPool & pool)
    {
        std::vector<std::unique_ptr<Map>> intermediate_results;

        Stopwatch watch;

        Aggregate::execute(data, num_threads, intermediate_results, std::forward<Creator>(creator), std::forward<Updater>(updater), pool);
        size_t num_maps = intermediate_results.size();

        watch.stop();
        double time_aggregated = watch.elapsedSeconds();
        std::cerr
            << "Aggregated in " << time_aggregated
            << " (" << data.size() / time_aggregated << " elem/sec.)"
            << std::endl;

        size_t size_before_merge = 0;
        std::cerr << "Sizes: ";
        for (size_t i = 0; i < num_threads; ++i)
        {
            std::cerr << (i == 0 ? "" : ", ") << intermediate_results[i]->size();
            size_before_merge += intermediate_results[i]->size();
        }
        std::cerr << std::endl;

        watch.restart();

        std::vector<Map*> intermediate_results_ptrs(num_maps);
        for (size_t i = 0; i < num_maps; ++i)
            intermediate_results_ptrs[i] = intermediate_results[i].get();

        Map * result_map;
        Merge::execute(intermediate_results_ptrs.data(), num_maps, result_map, std::forward<Merger>(merger), pool);

        watch.stop();
        double time_merged = watch.elapsedSeconds();
        std::cerr
            << "Merged in " << time_merged
            << " (" << size_before_merge / time_merged << " elem/sec.)"
            << std::endl;

        double time_total = time_aggregated + time_merged;
        std::cerr
            << "Total in " << time_total
            << " (" << data.size() / time_total << " elem/sec.)"
            << std::endl;
        std::cerr << "Size: " << result_map->size() << std::endl << std::endl;
    }
コード例 #7
0
ファイル: tdriver-zdl.cpp プロジェクト: Kangmo/infinidb
	//--------------------------------------------------------------------------
	// test the saving and loading of a zdl file
	//--------------------------------------------------------------------------
	void load_save(){
	    typedef ElementType Element;

    	vector <Element> v;
    	for (uint i = 0; i < ::count1Set*8; i++)
    	    v.push_back(Element(i,i));
    	
    	vector<Element> v1;
    	vector<Element> v2;
    	vector<Element> v3;
    	
    	// save
    	ofstream f1;
    	ifstream f;
    	string filename = "zdl.txt";
    	uint64_t ctn = v.size();
    	f1.open(filename.c_str(), std::ios::binary);
    	f1.write((char *) &ctn, sizeof(ctn));
    	f1.write((char *) (v.begin().operator->()), sizeof(Element) * ctn);
    	f.close();
    	
    	// load
    	v1.push_back(Element(3,4));
    	f.open(filename.c_str(), std::ios::binary);
    	timer.start("read");
    	v1.resize(v1.size()+::count1Set*8);
    	f.read((char *) ((v1.begin()+1).operator->()), ctn * sizeof(Element));
    	cout << v1.size() << endl;
        timer.stop("read");
        cout << "E1: " << v1[0].first << endl;
        f.close();
        
        f.open(filename.c_str(), std::ios::binary);
        timer.start("assign");
        v2.assign(std::istream_iterator<Element>(f), 
        				std::istream_iterator<Element>());
        cout << v2.size() << endl;    				    
        timer.stop("assign");
        f.close();
        
        f.open(filename.c_str(), std::ios::binary);
        timer.start("insert");
        v3.insert(v3.end(), std::istream_iterator<Element>(f), 
        				std::istream_iterator<Element>());
        cout << v3.size() << endl;    				    
        timer.stop("insert");
        f.close();
        timer.finish();
    }
コード例 #8
0
ファイル: oricmd.cpp プロジェクト: ailidani/dfs
string OriCommand::cmd_merge(strstream &str)
{
#if defined(DEBUG) || defined(ORI_PERF)
    Stopwatch sw = Stopwatch();
    sw.start();
#endif /* DEBUG */

    FUSE_PLOG("Command: merge");

    string error;
    ObjectHash hash;
    strwstream resp;

    // Parse Command
    str.readHash(hash);

    RWKey::sp lock = priv->nsLock.writeLock();
    error = priv->merge(hash);
    lock.reset();

    if (error != "") {
        resp.writeUInt8(0);
        resp.writePStr(error);
    } else {
        resp.writeUInt8(1);
    }

#if defined(DEBUG) || defined(ORI_PERF)
    sw.stop();
    FUSE_PLOG("merge with: %s", hash.hex().c_str());
    FUSE_PLOG("merge elapsed %lluus", sw.getElapsedTime());
#endif /* DEBUG */

    return resp.str();
}
コード例 #9
0
void RunOCLMatMulForKernel(
	float * arg_A, size_t arg_hst_ptrA_dim1, size_t arg_hst_ptrA_dim2, 
	float * arg_C, size_t arg_hst_ptrC_dim1, size_t arg_hst_ptrC_dim2, 
	float * arg_B, size_t arg_hst_ptrB_dim1, size_t arg_hst_ptrB_dim2, 
	unsigned arg_wB, unsigned arg_wA, unsigned arg_hA
	)
{
  if (isFirstTime)
    {
      hst_ptrA = arg_A;
      hst_ptrA_dim1 = arg_hst_ptrA_dim1;
      hst_ptrA_dim2 = arg_hst_ptrA_dim2;
      hst_ptrC = arg_C;
      hst_ptrC_dim1 = arg_hst_ptrC_dim1;
      hst_ptrC_dim2 = arg_hst_ptrC_dim2;
      hst_ptrB = arg_B;
      hst_ptrB_dim1 = arg_hst_ptrB_dim1;
      hst_ptrB_dim2 = arg_hst_ptrB_dim2;
      wB = arg_wB;
      wA = arg_wA;
      hA = arg_hA;
      StartUpGPU();
      AllocateBuffers();
      cout << "$Defines " << KernelDefines << endl;
      compileKernel(
	"MatMulFor", "MatMulFor.cl", GetKernelCode(), 
	false, &MatMulForKernel, KernelDefines
	);
      SetArgumentsMatMulFor();
    }
  timer.start();
  ExecMatMulFor();
  cout << "$Time " << timer.stop() << endl;
}
コード例 #10
0
void RunOCLNBodyForKernel(
	float * arg_Mas, size_t arg_hst_ptrMas_dim1, float * arg_Pos, 
	size_t arg_hst_ptrPos_dim1, size_t arg_hst_ptrPos_dim2, float * arg_Forces, 
	size_t arg_hst_ptrForces_dim1, size_t arg_hst_ptrForces_dim2, size_t arg_N
	)
{
  if (isFirstTime)
    {
      hst_ptrMas = arg_Mas;
      hst_ptrMas_dim1 = arg_hst_ptrMas_dim1;
      hst_ptrPos = arg_Pos;
      hst_ptrPos_dim1 = arg_hst_ptrPos_dim1;
      hst_ptrPos_dim2 = arg_hst_ptrPos_dim2;
      hst_ptrForces = arg_Forces;
      hst_ptrForces_dim1 = arg_hst_ptrForces_dim1;
      hst_ptrForces_dim2 = arg_hst_ptrForces_dim2;
      N = arg_N;
      StartUpGPU();
      AllocateBuffers();
      cout << "$Defines " << KernelDefines << endl;
      compileKernel(
	"NBodyFor", "NBodyFor.cl", GetKernelCode(), 
	false, &NBodyForKernel, KernelDefines
	);
      SetArgumentsNBodyFor();
    }
  timer.start();
  ExecNBodyFor();
  cout << "$Time " << timer.stop() << endl;
}
コード例 #11
0
void test(size_t n, const char * name, F && kernel)
{
    x = 0;

    Stopwatch watch;
    Stopwatch watch_one;
    double max_seconds = 0;

    std::cerr << name << ":\n";

    for (size_t i = 0; i < n; ++i)
    {
        watch_one.restart();

        kernel();

        watch_one.stop();
        if (watch_one.elapsedSeconds() > max_seconds)
            max_seconds = watch_one.elapsedSeconds();
    }

    watch.stop();

    std::cerr
        << std::fixed << std::setprecision(2)
        << n << " ops in "
        << watch.elapsedSeconds() << " sec., "
        << n / watch.elapsedSeconds() << " ops/sec., "
        << "avg latency: " << watch.elapsedSeconds() / n * 1000000 << " μs, "
        << "max latency: " << max_seconds * 1000000 << " μs "
        << "(res = " << x << ")"
        << std::endl;
}
コード例 #12
0
ファイル: TestStopwatch.cpp プロジェクト: rdobson/openpegasus
int main(int argc, char** argv)
{
    verbose = getenv("PEGASUS_TEST_VERBOSE") ? true : false;

    Stopwatch sw;

    sw.start();

    System::sleep(5);

    sw.stop();

    double elapsed = sw.getElapsed();

    if(verbose)
    {
        sw.printElapsed();
    }

    PEGASUS_TEST_ASSERT((elapsed >= 4.5) && (elapsed <= 5.5));

    cout << argv[0] << " +++++ passed all tests" << endl;

    return 0;
}
コード例 #13
0
ファイル: tdriver-deliver.cpp プロジェクト: Kangmo/infinidb
void queuedBSBenchmark(int queueLength)
{
    ByteStream *bs;
    pthread_t threads[columns];
    uint i, rowCount = 1;
    JobStepAssociation inJs;

    for (i = 0; i < columns; ++i) {
        AnyDataListSPtr spdl1(new AnyDataList());

        FIFO<UintRowGroup>* dl1 = new FIFO<UintRowGroup>(1, fifoSize);

        dl1->OID(i);    // lineitem first col object id
        spdl1->fifoDL(dl1);
        inJs.outAdd(spdl1);

        pthread_create(&threads[i], 0, nextBandBenchProducer, dl1 );
        cout << "started thread " << i << endl;
    }

    DeliveryStep ds(inJs, JobStepAssociation(), 8);
	BSQueueMgr bsq(&ds, queueLength);
	stringstream ss;
	ss << "queuedBSBenchmark with " << columns << " columns and " << queueLength << " queue length\n";
	
    timer.start(ss.str());
	boost::thread(BSProjectThread(&bsq));
    while (rowCount != 0) {
        bs = bsq.getNextByteStream(rowCount);
		delete bs;
    }
    timer.stop(ss.str());
    for (i = 0; i < columns; ++i)
        pthread_join(threads[i], NULL);
}
コード例 #14
0
ファイル: boilerplate.cpp プロジェクト: dikujepsen/OpenTran
void RunOCLNBody2ForKernel(
	float * arg_Mas, size_t arg_hst_ptrMas_dim1, float * arg_Forces_y, 
	size_t arg_hst_ptrForces_y_dim1, size_t arg_hst_ptrForces_y_dim2, float * arg_Pos, 
	size_t arg_hst_ptrPos_dim1, size_t arg_hst_ptrPos_dim2, float * arg_Forces_x, 
	size_t arg_hst_ptrForces_x_dim1, size_t arg_hst_ptrForces_x_dim2, size_t arg_N
	)
{
  if (isFirstTime)
    {
      hst_ptrMas = arg_Mas;
      hst_ptrMas_dim1 = arg_hst_ptrMas_dim1;
      hst_ptrForces_y = arg_Forces_y;
      hst_ptrForces_y_dim1 = arg_hst_ptrForces_y_dim1;
      hst_ptrForces_y_dim2 = arg_hst_ptrForces_y_dim2;
      hst_ptrPos = arg_Pos;
      hst_ptrPos_dim1 = arg_hst_ptrPos_dim1;
      hst_ptrPos_dim2 = arg_hst_ptrPos_dim2;
      hst_ptrForces_x = arg_Forces_x;
      hst_ptrForces_x_dim1 = arg_hst_ptrForces_x_dim1;
      hst_ptrForces_x_dim2 = arg_hst_ptrForces_x_dim2;
      N = arg_N;
      StartUpGPU();
      AllocateBuffers();
      compileKernelFromFile(
	"NBody2For", "NBody2For.cl", KernelString(), 
	true, &NBody2ForKernel, KernelDefines
	);
      SetArgumentsNBody2For();
    }
  timer.start();
  ExecNBody2For();
  cout << timer.stop() << endl;
}
コード例 #15
0
ファイル: main.cpp プロジェクト: ongbe/Advanced-Graphics
void walk_tree()
{
    static Stopwatch timer;
    timer.start();
    
    scale_factor = sqrt(2.0*pow(((double)width/(bbmax-bbmin).max()), 2.0));
    
    vert_ls splats = sphere_tree->recurseToDepth(recursion_depth);
    
    splats.sort(testSize);
    
    maxSplatSize = scale_factor * (splats.front()->size - splats.back()-> size)/2.0;
    
    fastSplats.clear();    
    fastSplats.reserve(splats.size());
    
    for (vert_it it = splats.begin(); it != splats.end(); it++)
    {
        fastSplats.push_back(**it);
    }

    splatParts.clear();
    splatSizes.clear();
    
    partitionSizes(fastSplats.begin(), fastSplats.end(), 5);
    
    splatParts.push_back(fastSplats.end());
    
    cout << splatSizes.size() << endl;
    
    timer.stop();
    printf("Recursed to depth %u in %f seconds\n", recursion_depth, timer.time());
    printf("Displaying %lu splats, with %lu sizes\n", splats.size(), splatSizes.size() );
    timer.reset();
}
コード例 #16
0
Result benchmarkSingleRun(OpenANN::Environment& environment, OpenANN::Agent& agent)
{
  Result result;
  int maximalEpisodes = 100000;
  int requiredSteps = 100000;
  agent.abandoneIn(environment);

  result.success = false;
  Stopwatch sw;
  for(int i = 1; i <= maximalEpisodes; i++)
  {
    environment.restart();
    while(!environment.terminalState())
      agent.chooseAction();
    if(environment.stepsInEpisode() >= requiredSteps)
    {
      result.success = true;
      result.episodes = i;
      break;
    }
  }
  result.time = sw.stop(Stopwatch::MILLISECOND);

  return result;
}
コード例 #17
0
ファイル: MiniSeisSol.cpp プロジェクト: SeisSol/SeisSol
double seissol::miniSeisSol(initializers::MemoryManager& memoryManager) {
  struct GlobalData* globalData = memoryManager.getGlobalData();

  initializers::LTSTree ltsTree;
  initializers::LTS     lts;
  
  lts.addTo(ltsTree);
  ltsTree.setNumberOfTimeClusters(1);
  ltsTree.fixate();
  
  initializers::TimeCluster& cluster = ltsTree.child(0);
  cluster.child<Ghost>().setNumberOfCells(0);
  cluster.child<Copy>().setNumberOfCells(0);
  cluster.child<Interior>().setNumberOfCells(50000);

  ltsTree.allocateVariables();
  ltsTree.touchVariables();
  
  initializers::Layer& layer = cluster.child<Interior>();
  
  layer.setBucketSize(lts.buffersDerivatives, sizeof(real) * tensor::I::size() * layer.getNumberOfCells());
  ltsTree.allocateBuckets();
  
  fakeData(lts, layer);
  
  localIntegration(globalData, lts, layer);
  
  Stopwatch stopwatch;
  stopwatch.start();
  for (unsigned t = 0; t < 10; ++t) {
    localIntegration(globalData, lts, layer);
  }
  return stopwatch.stop();
}
コード例 #18
0
ファイル: iotest_aio.cpp プロジェクト: Aahart911/ClickHouse
int mainImpl(int argc, char ** argv)
{
	const char * file_name = 0;
	int mode = MODE_READ;
	size_t min_offset = 0;
	size_t max_offset = 0;
	size_t block_size = 0;
	size_t buffers_count = 0;
	size_t threads_count = 0;
	size_t count = 0;

	if (argc != 9)
	{
		std::cerr << "Usage: " << argv[0] << " file_name r|w min_offset max_offset block_size threads buffers count" << std::endl;
		return 1;
	}

	file_name = argv[1];
	if (argv[2][0] == 'w')
		mode = MODE_WRITE;
	min_offset = Poco::NumberParser::parseUnsigned64(argv[3]);
	max_offset = Poco::NumberParser::parseUnsigned64(argv[4]);
	block_size = Poco::NumberParser::parseUnsigned64(argv[5]);
	threads_count = Poco::NumberParser::parseUnsigned(argv[6]);
	buffers_count = Poco::NumberParser::parseUnsigned(argv[7]);
	count = Poco::NumberParser::parseUnsigned(argv[8]);

	int fd = open(file_name, ((mode == MODE_READ) ? O_RDONLY : O_WRONLY) | O_DIRECT);
	if (-1 == fd)
		throwFromErrno("Cannot open file");

	using Exceptions = std::vector<std::exception_ptr>;

	boost::threadpool::pool pool(threads_count);
	Exceptions exceptions(threads_count);

	Stopwatch watch;

	for (size_t i = 0; i < threads_count; ++i)
		pool.schedule(std::bind(thread, fd, mode, min_offset, max_offset, block_size, buffers_count, count, std::ref(exceptions[i])));
	pool.wait();

	watch.stop();

	for (size_t i = 0; i < threads_count; ++i)
		if (exceptions[i])
			std::rethrow_exception(exceptions[i]);

	if (0 != close(fd))
		throwFromErrno("Cannot close file");

	std::cout << std::fixed << std::setprecision(2)
	<< "Done " << count << " * " << threads_count << " ops";
	std::cout << " in " << watch.elapsedSeconds() << " sec."
	<< ", " << count * threads_count / watch.elapsedSeconds() << " ops/sec."
	<< ", " << count * threads_count * block_size / watch.elapsedSeconds() / 1000000 << " MB/sec."
	<< std::endl;

	return 0;
}
コード例 #19
0
void RunOCLKNearestForKernel(
	unsigned arg_dim, float * arg_test_patterns, size_t arg_hst_ptrtest_patterns_dim1, 
	size_t arg_hst_ptrtest_patterns_dim2, float * arg_dist_matrix, size_t arg_hst_ptrdist_matrix_dim1, 
	size_t arg_hst_ptrdist_matrix_dim2, float * arg_train_patterns, size_t arg_hst_ptrtrain_patterns_dim1, 
	size_t arg_hst_ptrtrain_patterns_dim2, unsigned arg_NTEST, unsigned arg_NTRAIN
	)
{
  if (isFirstTime)
    {
      dim = arg_dim;
      hst_ptrtest_patterns = arg_test_patterns;
      hst_ptrtest_patterns_dim1 = arg_hst_ptrtest_patterns_dim1;
      hst_ptrtest_patterns_dim2 = arg_hst_ptrtest_patterns_dim2;
      hst_ptrdist_matrix = arg_dist_matrix;
      hst_ptrdist_matrix_dim1 = arg_hst_ptrdist_matrix_dim1;
      hst_ptrdist_matrix_dim2 = arg_hst_ptrdist_matrix_dim2;
      hst_ptrtrain_patterns = arg_train_patterns;
      hst_ptrtrain_patterns_dim1 = arg_hst_ptrtrain_patterns_dim1;
      hst_ptrtrain_patterns_dim2 = arg_hst_ptrtrain_patterns_dim2;
      NTEST = arg_NTEST;
      NTRAIN = arg_NTRAIN;
      StartUpGPU();
      AllocateBuffers();
      cout << "$Defines " << KernelDefines << endl;
      compileKernel(
	"KNearestFor", "KNearestFor.cl", GetKernelCode(), 
	false, &KNearestForKernel, KernelDefines
	);
      SetArgumentsKNearestFor();
    }
  timer.start();
  ExecKNearestFor();
  cout << "$Time " << timer.stop() << endl;
}
コード例 #20
0
void NO_INLINE bench(const std::vector<UInt16> & data, const char * name)
{
    Map map;
    typename Map::iterator it;
    bool inserted;

    Stopwatch watch;
    for (size_t i = 0, size = data.size(); i < size; ++i)
    {
        map.emplace(data[i], it, inserted);
        if (inserted)
            it->getSecond() = 1;
        else
            ++it->getSecond();
    }

    for (size_t i = 0, size = data.size(); i < size; ++i)
    {
        it = map.find(data[i]);
        ++it->getSecond();
    }
    watch.stop();
    std::cerr << std::fixed << std::setprecision(2) << "HashMap (" << name << "). Size: " << map.size()
              << ", elapsed: " << watch.elapsedSeconds() << " (" << data.size() / watch.elapsedSeconds() << " elem/sec.)"
#ifdef DBMS_HASH_MAP_COUNT_COLLISIONS
              << ", collisions: " << map.getCollisions()
#endif
              << std::endl;
}
コード例 #21
0
    std::int64_t OneToOneSequencedBatchThroughputTest::run(Stopwatch& stopwatch)
    {
        m_taskScheduler->start(requiredProcessorCount());
        TestTools::ScopeExitFunctor atScopeExit([this] { m_taskScheduler->stop(); });

        auto signal = std::make_shared< Tests::ManualResetEvent >(false);
        auto expectedCount = m_batchEventProcessor->sequence()->value() + m_iterations * m_batchSize;
        m_handler->reset(signal, expectedCount);
        auto processorTask = m_executor->execute([this] { m_batchEventProcessor->run(); });
        stopwatch.start();

        auto&& rb = *m_ringBuffer;

        for (auto i = 0; i < m_iterations; ++i)
        {
            auto hi = rb.next(m_batchSize);
            auto lo = hi - (m_batchSize - 1);
            for (auto l = lo; l <= hi; ++l)
            {
                rb[l].value = (i);
            }
            rb.publish(lo, hi);
        }

        signal->waitOne();
        stopwatch.stop();
        PerfTestUtil::waitForEventProcessorSequence(expectedCount, m_batchEventProcessor);
        m_batchEventProcessor->halt();
        processorTask.wait_for(std::chrono::milliseconds(2000));

        PerfTestUtil::failIfNot(m_expectedResult, m_handler->value(),
                                "Handler should have processed " + std::to_string(m_expectedResult) + " events, but was: " + std::to_string(m_handler->value()));

        return m_batchSize * m_iterations;
    }
コード例 #22
0
ファイル: folly_dynamic.cpp プロジェクト: aleks-f/articles
void doFollyDynamic(std::vector<std::string> strvec) 
{
	std::cout << "folly::dynamic" << std::endl;
	std::cout << "==============" << std::endl;

	std::vector<std::string>::iterator it = strvec.begin();
	std::vector<std::string>::iterator end = strvec.end();

	Stopwatch sw;
	sw.start();
	for (; it != end; ++it)
	{
		dynamic var(*it);
		
		int i = var.asInt();
	
		double d = var.asDouble();

		var = i;
		std::string s = var.asString().c_str();

		var = d;
		s = var.asString().c_str();
	}
	sw.stop();
	std::cout << "folly::dynamic: " << sw.elapsed()/1000.0 << " [ms]" << std::endl;
	
	std::cout << "==============" << std::endl;
}
コード例 #23
0
int main(int argc, char ** argv)
{
	try
	{
		DB::ReadBufferFromFileDescriptor in(STDIN_FILENO);
		Int64 n = 0;
		size_t nums = 0;

		Stopwatch watch;

		while (!in.eof())
		{
			DB::readIntText(n, in);
			in.ignore();

			//std::cerr << "n: " << n << std::endl;

			++nums;
		}

		watch.stop();
		std::cerr << std::fixed << std::setprecision(2)
			<< "Read " << nums << " numbers (" << in.count() / 1000000.0 << " MB) in " << watch.elapsedSeconds() << " sec., "
			<< nums / watch.elapsedSeconds() << " num/sec. (" << in.count() / watch.elapsedSeconds() / 1000000 << " MB/s.)"
			<< std::endl;
	}
	catch (const DB::Exception & e)
	{
		std::cerr << e.what() << ", " << e.displayText() << std::endl;
		return 1;
	}

	return 0;
}
コード例 #24
0
    void PingPongSequencedLatencyTest::run(Stopwatch& stopwatch, const std::shared_ptr< Tests::LatencyRecorder >& latencyRecorder)
    {
        m_taskScheduler->start(requiredProcessorCount());
        TestTools::ScopeExitFunctor atScopeExit([this] { m_taskScheduler->stop(); });

        auto globalSignal = std::make_shared< Tests::CountdownEvent >(3);
        auto signal = std::make_shared< Tests::ManualResetEvent >(false);
        m_pinger->reset(globalSignal, signal, latencyRecorder);
        m_ponger->reset(globalSignal);

        auto processorTask1 = m_executor->execute([this] { m_pongProcessor->run(); });
        auto processorTask2 = m_executor->execute([this] { m_pingProcessor->run(); });

        globalSignal->signal();
        globalSignal->wait();
        stopwatch.start();
        // running here
        signal->waitOne();
        stopwatch.stop();

        m_pingProcessor->halt();
        m_pongProcessor->halt();

        processorTask1.wait();
        processorTask2.wait();
    }
コード例 #25
0
void NO_INLINE bench(const std::vector<StringRef> & data, const char * name)
{
	Stopwatch watch;

	using Map = HashMapWithSavedHash<Key, Value, DefaultHash<Key>>;

	Map map;
	typename Map::iterator it;
	bool inserted;

	for (size_t i = 0, size = data.size(); i < size; ++i)
	{
		map.emplace(static_cast<const Key &>(data[i]), it, inserted);
		if (inserted)
			it->second = 0;
		++it->second;
	}

	watch.stop();
	std::cerr << std::fixed << std::setprecision(2)
		<< "HashMap (" << name << "). Size: " << map.size()
		<< ", elapsed: " << watch.elapsedSeconds()
		<< " (" << data.size() / watch.elapsedSeconds() << " elem/sec.)"
#ifdef DBMS_HASH_MAP_COUNT_COLLISIONS
		<< ", collisions: " << map.getCollisions()
#endif
		<< std::endl;
}
コード例 #26
0
void RunOCLJacobiForKernel(
	float * arg_X2, size_t arg_hst_ptrX2_dim1, size_t arg_hst_ptrX2_dim2, 
	float * arg_X1, size_t arg_hst_ptrX1_dim1, size_t arg_hst_ptrX1_dim2, 
	float * arg_B, size_t arg_hst_ptrB_dim1, size_t arg_hst_ptrB_dim2, 
	unsigned arg_wB, unsigned arg_wA)
{
  if (isFirstTime)
    {
      hst_ptrX2 = arg_X2;
      hst_ptrX2_dim1 = arg_hst_ptrX2_dim1;
      hst_ptrX2_dim2 = arg_hst_ptrX2_dim2;
      hst_ptrX1 = arg_X1;
      hst_ptrX1_dim1 = arg_hst_ptrX1_dim1;
      hst_ptrX1_dim2 = arg_hst_ptrX1_dim2;
      hst_ptrB = arg_B;
      hst_ptrB_dim1 = arg_hst_ptrB_dim1;
      hst_ptrB_dim2 = arg_hst_ptrB_dim2;
      wB = arg_wB;
      wA = arg_wA;
      StartUpGPU();
      AllocateBuffers();
      cout << "$Defines " << KernelDefines << endl;
      compileKernel(
	"JacobiFor", "JacobiFor.cl", GetKernelCode(), 
	false, &JacobiForKernel, KernelDefines
	);
      SetArgumentsJacobiFor();
    }
  timer.start();
  ExecJacobiFor();
  cout << "$Time " << timer.stop() << endl;
}
コード例 #27
0
ファイル: tdriver-zdl.cpp プロジェクト: Kangmo/infinidb
	void SWSDL_bench_mulSet_seq()
	{	   
		typedef ElementType Element;

	    id_sw = 0;
		uint i;
		uint numOfProducers = NUM_PRODUCERS;
		uint numOfConsumers = NUM_CONSUMERS;
		SWSDL<Element> sw(numOfConsumers, fRm);
        sw.setMultipleProducers(true);
		
		pthread_t producer[numOfProducers];
		pthread_t consumer[numOfConsumers];
		struct timespec ts1, ts2, diff;
        
        timer.start("swsdl-produce");
		clock_gettime(CLOCK_REALTIME, &ts1);
		for (i = 0; i < numOfProducers; i++)
		    pthread_create(&producer[i], NULL,
				SWSDL_producer_mulSet_seq<Element>, &sw);
		    
		for (i = 0; i < numOfProducers; i++)
		    pthread_join(producer[i], NULL);
        timer.stop("swsdl-produce");
        timer.start("swsdl-endofinput");
		sw.endOfInput();
		timer.stop("swsdl-endofinput");
		
		//timer.stop("swsdl-produce");
		timer.start("swsdl-consume");
		for (i = 0; i < numOfConsumers; i++)
		    pthread_create(&consumer[i], NULL,
				SWSDL_consumer<Element>, &sw);
		for (i = 0; i < numOfConsumers; i++)
		    pthread_join(consumer[i], NULL);

		clock_gettime(CLOCK_REALTIME, &ts2);
		timer.stop("swsdl-consume");
		timer.finish();
		timespec_sub(ts1, ts2, diff);

        cout << "# of Producers: " << numOfProducers << endl;
        cout << "# of Consumers: " << numOfConsumers << endl;
		cout << "SWSDL_bench_mulSet_seq: producer & consumer passed " << 
			sw.totalSize() << " elements in " << diff.tv_sec << "s " <<
			diff.tv_nsec << "ns" << endl;
	}
コード例 #28
0
TEST(METRICS_STOPWATCH, Short)
{
    Stopwatch sw;
    sw.start();
    Timer::sleepMsec(1);
    int64_t diff = sw.stop();
    ASSERT_EQ(diff, 1);
}
コード例 #29
0
TEST(METRICS_STOPWATCH, Long)
{
    Stopwatch sw;
    sw.start();
    Timer::sleepMsec(100);
    int64_t diff = sw.stop();
    ASSERT_TRUE(diff >= 99 && diff <= 101);
}
コード例 #30
0
int TextTestRunner::run(TestCase& testCase)
{
  testCase.testResult.attach(this);
  Stopwatch sw;
  testCase.run();
  std::cout << sw.stop() << " mus" << std::endl;
  testCase.testResult.detach(this);
  return testCase.testResult.total - testCase.testResult.successful;
}