File: tresources.cpp

package info (click to toggle)
wsclean 3.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,296 kB
  • sloc: cpp: 129,246; python: 22,066; sh: 360; ansic: 230; makefile: 185
file content (50 lines) | stat: -rw-r--r-- 1,199 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

#include "../../structures/resources.h"

#include <aocommon/logger.h>

#include <boost/test/unit_test.hpp>

namespace wsclean {

namespace {
const int64_t gb = 1024u * 1024u * 1024u;
}

BOOST_AUTO_TEST_SUITE(resources)

BOOST_AUTO_TEST_CASE(get_part) {
  const Resources r(8, 8 * gb);

  const Resources quarter = r.GetPart(4);
  BOOST_TEST(quarter.NCpus() == 2);
  BOOST_TEST(quarter.Memory() == 2 * gb);

  // Always at least one cpu?
  BOOST_TEST(r.GetPart(16).NCpus() == 1);

  // Round up?
  BOOST_TEST(r.GetPart(3).NCpus() == 3);
}

BOOST_AUTO_TEST_CASE(get_available_memory) {
  aocommon::Logger::SetVerbosity(aocommon::LogVerbosityLevel::kQuiet);
  const int64_t all_memory = GetAvailableMemory(1.0, 0.0);
  BOOST_TEST(all_memory > 0);

  const int64_t half = GetAvailableMemory(0.5, 0.0);
  BOOST_TEST(half > all_memory * 0.4);
  BOOST_TEST(half < all_memory * 0.6);

  const int64_t max_1gb = GetAvailableMemory(1.0, 1.0);
  BOOST_TEST(max_1gb <= all_memory);
  BOOST_TEST(max_1gb <= gb);

  const int64_t max_1gb_half = GetAvailableMemory(0.5, 1.0);
  BOOST_TEST(max_1gb_half < all_memory * 0.6);
  BOOST_TEST(max_1gb_half <= gb);
}

BOOST_AUTO_TEST_SUITE_END()

}  // namespace wsclean