Skip to content

Commit

Permalink
revert the changes in test/unit
Browse files Browse the repository at this point in the history
  • Loading branch information
Change72 committed Oct 18, 2024
1 parent 02e0b2e commit 3f07eab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 99 deletions.
2 changes: 1 addition & 1 deletion tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ target_include_directories(test_geos_unit
file(GLOB_RECURSE _testfiles ${CMAKE_CURRENT_LIST_DIR}/**/*Test.cpp CONFIGURE_DEPEND)
foreach(_testfile ${_testfiles})
string(REPLACE ${CMAKE_CURRENT_LIST_DIR}/ "" _testname ${_testfile})
string(REPLACE "../../test.cpp" "" _testname ${_testname})
string(REPLACE "Test.cpp" "" _testname ${_testname})
string(REPLACE "/" "-" _cmake_testname ${_testname})
string(REPLACE "/" "::" _testname ${_testname})
if (NOT ${_testname} MATCHES "^capi::")
Expand Down
99 changes: 1 addition & 98 deletions tests/unit/index/strtree/SimpleSTRtreeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,8 @@
#include <geos/index/strtree/GeometryItemDistance.h>
#include <geos/index/ItemVisitor.h>
#include <geos/io/WKTReader.h>
#include <geos/geom/Envelope3d.h>
#include <iostream>
#include <ctime>
#include <iostream>
#include <thread>
#include <chrono>
#include <string.h>

#ifdef WIN32
#include <windows.h>
#include <psapi.h>
//#include <tlhelp32.h>
#include <direct.h>
#include <process.h>
#else
#include <sys/stat.h>
//#include <sys/sysinfo.h>
#include <sys/time.h>
#include <unistd.h>
#endif
#include <google/protobuf/io/coded_stream.h>
// get current process pid
inline int GetCurrentPid()
{
return getpid();
}

#define VMRSS_LINE 22

#include <iostream>

using namespace geos;

Expand Down Expand Up @@ -181,76 +154,6 @@ void object::test<3>
}


// get specific process physical memeory occupation size by pid (MB)
inline float GetMemoryUsage(int pid)
{
#ifdef WIN32
uint64_t mem = 0, vmem = 0;
PROCESS_MEMORY_COUNTERS pmc;

// get process hanlde by pid
HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
if (GetProcessMemoryInfo(process, &pmc, sizeof(pmc)))
{
mem = pmc.WorkingSetSize;
vmem = pmc.PagefileUsage;
}
CloseHandle(process);

// use GetCurrentProcess() can get current process and no need to close handle

// convert mem from B to MB
return mem / 1024.0 / 1024.0;

#else
char file_name[64] = { 0 };
FILE* fd;
char line_buff[512] = { 0 };
sprintf(file_name, "/proc/%d/status", pid);

fd = fopen(file_name, "r");
if (nullptr == fd)
return 0;

char name[64];
int vmrss = 0;
for (int i = 0; i < VMRSS_LINE - 1; i++)
fgets(line_buff, sizeof(line_buff), fd);

fgets(line_buff, sizeof(line_buff), fd);
sscanf(line_buff, "%s %d", name, &vmrss);
fclose(fd);

// cnvert VmRSS from KB to MB
return float(vmrss / 1024.0);
#endif
}



template<>
template<>
void object::test<4>
() {

index::strtree::SimpleSTRtree t(10);
std::vector<std::unique_ptr<geom::Geometry>> geoms;
const int gridSize = 100;
const int gap = 10;
auto gf = geom::GeometryFactory::create();

for (int i = 0; i < gridSize; ++i) {
for (int j = 0; j < gridSize; ++j) {
for (int k= 0; k < gridSize; ++k) {
geos::geom::Envelope3d e(i, i + gap, j, j + gap, k, k + gap);
const auto ep = &e;
t.insert(ep, static_cast<void*>(&e));
}
}
}
t.getRoot3d();

}

} // namespace tut

0 comments on commit 3f07eab

Please sign in to comment.