Skip to content

Commit ef8ebe3

Browse files
authored
Merge branch 'PHAREHUB:master' into vtk
2 parents 3b0b379 + 238185f commit ef8ebe3

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

tools/bench/amr/data/particles/copy_data.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ParticleDataCopy : public benchmark::Fixture
2929

3030
data->sourceData.domainParticles = PHARE::core::bench::make_particles<dim>(ppc, sourceBox);
3131
assert(data->sourceData.domainParticles.size() == ppc * sourceBox.size());
32+
assert(data->destData.domainParticles.size() == 0);
3233
}
3334

3435
void TearDown(::benchmark::State const& /*state*/) override {}
@@ -37,9 +38,9 @@ class ParticleDataCopy : public benchmark::Fixture
3738

3839
private:
3940
static const inline PHARE::amr::Box<int, dim> sourceBox{PHARE::core::ConstArray<int, dim>(0),
40-
PHARE::core::ConstArray<int, dim>(999)};
41-
static const inline PHARE::amr::Box<int, dim> destBox{PHARE::core::ConstArray<int, dim>(500),
42-
PHARE::core::ConstArray<int, dim>(1499)};
41+
PHARE::core::ConstArray<int, dim>(19)};
42+
static const inline PHARE::amr::Box<int, dim> destBox{PHARE::core::ConstArray<int, dim>(10),
43+
PHARE::core::ConstArray<int, dim>(19)};
4344

4445

4546
struct _DATA_ // gbench static init doesn't play well with SAMRAI
@@ -61,7 +62,10 @@ template<std::size_t dim, std::size_t interp, std::size_t op>
6162
void ParticleDataCopy<dim, interp, op>::copy_data(::benchmark::State& state)
6263
{
6364
for (auto _ : state)
65+
{
6466
this->data->destData.copy(this->data->sourceData);
67+
data->destData.domainParticles.clear();
68+
}
6569
}
6670

6771
BENCHMARK_TEMPLATE_DEFINE_F(ParticleDataCopy, _2_1_1, 2, 1, 1)(benchmark::State& state)

tools/bench/core/bench.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#ifndef PHARE_BENCH_CORE_BENCH_H
22
#define PHARE_BENCH_CORE_BENCH_H
33

4-
#include "core/utilities/box/box.hpp"
5-
64
#include "phare_core.hpp"
75

6+
#include "core/utilities/box/box.hpp"
7+
88
#include "tests/core/data/vecfield/test_vecfield_fixtures.hpp"
99
#include "tests/core/data/electromag/test_electromag_fixtures.hpp"
1010

1111
#include "benchmark/benchmark.h"
12+
1213
#include <fstream>
13-
#include <iterator>
1414

1515
namespace PHARE::core::bench
1616
{
@@ -60,8 +60,7 @@ template<std::size_t dim, typename ParticleArray_t = PHARE::core::ParticleArray<
6060
auto make_particles(std::size_t n_particles)
6161
{
6262
auto particles = ParticleArray_t{Box<int, dim>{}};
63-
particles.vector()
64-
= std::vector<typename ParticleArray_t::value_type>(n_particles, particle<dim>());
63+
particles.vector().resize(n_particles, particle<dim>());
6564
return particles;
6665
}
6766

@@ -93,10 +92,11 @@ void disperse(Particles& particles, std::size_t lo, std::size_t up,
9392
disperse(particles, core::ConstArray<int, dim>(lo), core::ConstArray<int, dim>(up), seed);
9493
}
9594

96-
template<std::size_t dim, typename Box>
95+
template<std::size_t dim, typename Box, typename ParticleArray_t = PHARE::core::ParticleArray<dim>>
9796
auto make_particles(std::size_t ppc, Box disperse_in, std::optional<int> seed = std::nullopt)
9897
{
99-
auto particles = make_particles<dim>(ppc * disperse_in.size());
98+
auto particles = ParticleArray_t{disperse_in};
99+
particles.vector().resize(ppc * disperse_in.size(), particle<dim>());
100100
disperse(particles, disperse_in.lower, disperse_in.upper, seed);
101101
return particles;
102102
}

0 commit comments

Comments
 (0)