Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 13abe99bc2ad
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4d10a2d1444c
Choose a head ref
  • 5 commits
  • 5 files changed
  • 1 contributor

Commits on Aug 31, 2017

  1. Benchmark for Plugin.

    pleroy committed Aug 31, 2017
    Copy the full SHA
    6ade7c3 View commit details
  2. Copy the full SHA
    8b1e9ea View commit details
  3. Bin file.

    pleroy committed Aug 31, 2017
    Copy the full SHA
    e7af1f1 View commit details
  4. Lint.

    pleroy committed Aug 31, 2017
    Copy the full SHA
    3c382d6 View commit details
  5. Merge pull request #1548 from pleroy/Benchmark3

    A benchmark for Plugin and proper parallelism
    pleroy authored Aug 31, 2017
    Copy the full SHA
    4d10a2d View commit details
3 changes: 2 additions & 1 deletion ksp_plugin/plugin.cpp
Original file line number Diff line number Diff line change
@@ -1206,7 +1206,8 @@ Plugin::Plugin(
: history_parameters_(history_parameters),
prolongation_parameters_(prolongation_parameters),
prediction_parameters_(prediction_parameters),
vessel_thread_pool_(/*pool_size=*/1) {}
vessel_thread_pool_(
/*pool_size=*/2 * std::thread::hardware_concurrency()) {}

void Plugin::InitializeIndices(
std::string const& name,
Binary file added ksp_plugin_test/3 vessels.proto.bin
Binary file not shown.
70 changes: 70 additions & 0 deletions ksp_plugin_test/benchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

#include "ksp_plugin/plugin.hpp"

#include <string>
#include <vector>

#include "benchmark/benchmark.h"
#include "geometry/named_quantities.hpp"
#include "gtest/gtest.h"
#include "ksp_plugin/interface.hpp"
#include "quantities/quantities.hpp"
#include "serialization/ksp_plugin.pb.h"
#include "testing_utilities/serialization.hpp"

namespace principia {

using geometry::Instant;
using interface::principia__AdvanceTime;
using interface::principia__FutureCatchUpVessel;
using interface::principia__FutureWait;
using quantities::Frequency;
using quantities::Time;
using quantities::si::Hertz;
using quantities::si::Second;
using testing_utilities::ReadFromBinaryFile;

namespace ksp_plugin {

void BM_PluginIntegrationBenchmark(benchmark::State& state) {
std::string const binary_plugin = ReadFromBinaryFile(
SOLUTION_DIR / "ksp_plugin_test" / "3 vessels.proto.bin");
serialization::Plugin serialized_plugin;
// TODO(phl): For some reason this doesn't CHECK because it wants to read
// beyond the end |binary_plugin|. Figure out why (could it be an extra
// byte?).
serialized_plugin.ParseFromString(binary_plugin);
auto const plugin = Plugin::ReadFromMessage(serialized_plugin);

std::vector<GUID> const vessel_guids = {
"70ff8dc0-a4dd-4b8c-868b-35ddb01e32bc",
"abd95a7e-6b8b-4dba-a1e9-c96cd594cd67",
"b86d2efd-5150-4a44-8c36-04820a85e861"};

static constexpr int warp_factor = 6E6;
static constexpr Frequency refresh_frequency = 50 * Hertz;
static constexpr Time step = warp_factor / refresh_frequency;
while (state.KeepRunning()) {
principia__AdvanceTime(
plugin.get(),
(plugin->CurrentTime() + step - plugin->GameEpoch()) / Second,
/*planetarium_rotation=*/45);
std::vector<std::future<void> const*> futures;
for (GUID const& vessel_guid : vessel_guids) {
futures.push_back(
principia__FutureCatchUpVessel(plugin.get(), vessel_guid.c_str()));
}
for (auto& future : futures) {
principia__FutureWait(&future);
}
}
}

BENCHMARK(BM_PluginIntegrationBenchmark);

TEST(PluginBenchmark, DISABLED_3Vessels) {
benchmark::RunSpecifiedBenchmarks();
}

} // namespace ksp_plugin
} // namespace principia
14 changes: 14 additions & 0 deletions ksp_plugin_test/ksp_plugin_test.vcxproj
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@
<ClCompile Include="..\ksp_plugin\plugin.cpp" />
<ClCompile Include="..\ksp_plugin\renderer.cpp" />
<ClCompile Include="..\ksp_plugin\vessel.cpp" />
<ClCompile Include="benchmark.cpp" />
<ClCompile Include="celestial_test.cpp" />
<ClCompile Include="flight_plan_test.cpp" />
<ClCompile Include="interface_flight_plan_test.cpp" />
@@ -86,6 +87,7 @@
<ClInclude Include="mock_vessel.hpp" />
</ItemGroup>
<ItemGroup>
<None Include="3 vessels.proto.bin" />
<None Include="simple_plugin.proto.bin" />
<None Include="simple_plugin.proto.hex" />
</ItemGroup>
@@ -140,6 +142,7 @@
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\google_benchmark.props" />
<Import Project="..\warnings_as_errors.props" />
<Import Project="..\third_party_optional.props" />
<Import Project="..\suppress_useless_warnings.props" />
@@ -153,10 +156,13 @@
<Import Project="..\..\Google\glog\vsprojects\static_linking.props" />
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\..\Google\benchmark\msvc\windows_libraries.props" />
<Import Project="..\..\Google\benchmark\msvc\portability_macros.props" />
<Import Project="..\generate_version_translation_unit.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\google_benchmark.props" />
<Import Project="..\warnings_as_errors.props" />
<Import Project="..\third_party_optional.props" />
<Import Project="..\suppress_useless_warnings.props" />
@@ -170,10 +176,13 @@
<Import Project="..\..\Google\glog\vsprojects\static_linking.props" />
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\..\Google\benchmark\msvc\windows_libraries.props" />
<Import Project="..\..\Google\benchmark\msvc\portability_macros.props" />
<Import Project="..\generate_version_translation_unit.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\google_benchmark.props" />
<Import Project="..\warnings_as_errors.props" />
<Import Project="..\third_party_optional.props" />
<Import Project="..\suppress_useless_warnings.props" />
@@ -187,11 +196,14 @@
<Import Project="..\..\Google\glog\vsprojects\static_linking.props" />
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\..\Google\benchmark\msvc\windows_libraries.props" />
<Import Project="..\..\Google\benchmark\msvc\portability_macros.props" />
<Import Project="..\generate_version_translation_unit.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\google_benchmark.props" />
<Import Project="..\warnings_as_errors.props" />
<Import Project="..\third_party_optional.props" />
<Import Project="..\suppress_useless_warnings.props" />
@@ -205,6 +217,8 @@
<Import Project="..\..\Google\glog\vsprojects\static_linking.props" />
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\..\Google\benchmark\msvc\windows_libraries.props" />
<Import Project="..\..\Google\benchmark\msvc\portability_macros.props" />
<Import Project="..\generate_version_translation_unit.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
6 changes: 6 additions & 0 deletions ksp_plugin_test/ksp_plugin_test.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -155,6 +155,9 @@
<ClCompile Include="..\ksp_plugin\interface_future.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="benchmark.cpp">
<Filter>Test Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="mock_plugin.hpp">
@@ -188,5 +191,8 @@
<None Include="simple_plugin.proto.hex">
<Filter>Resource Files</Filter>
</None>
<None Include="3 vessels.proto.bin">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>