|
7 | 7 | #include <geos/index/strtree/GeometryItemDistance.h> |
8 | 8 | #include <geos/index/ItemVisitor.h> |
9 | 9 | #include <geos/io/WKTReader.h> |
10 | | -#include <geos/geom/Envelope3d.h> |
11 | | -#include <iostream> |
12 | | -#include <ctime> |
13 | | -#include <iostream> |
14 | | -#include <thread> |
15 | | -#include <chrono> |
16 | | -#include <string.h> |
17 | | - |
18 | | -#ifdef WIN32 |
19 | | -#include <windows.h> |
20 | | -#include <psapi.h> |
21 | | -//#include <tlhelp32.h> |
22 | | -#include <direct.h> |
23 | | -#include <process.h> |
24 | | -#else |
25 | | -#include <sys/stat.h> |
26 | | -//#include <sys/sysinfo.h> |
27 | | -#include <sys/time.h> |
28 | | -#include <unistd.h> |
29 | | -#endif |
30 | | -#include <google/protobuf/io/coded_stream.h> |
31 | | -// get current process pid |
32 | | -inline int GetCurrentPid() |
33 | | -{ |
34 | | - return getpid(); |
35 | | -} |
36 | | - |
37 | | -#define VMRSS_LINE 22 |
38 | 10 |
|
| 11 | +#include <iostream> |
39 | 12 |
|
40 | 13 | using namespace geos; |
41 | 14 |
|
@@ -181,76 +154,6 @@ void object::test<3> |
181 | 154 | } |
182 | 155 |
|
183 | 156 |
|
184 | | -// get specific process physical memeory occupation size by pid (MB) |
185 | | -inline float GetMemoryUsage(int pid) |
186 | | -{ |
187 | | -#ifdef WIN32 |
188 | | - uint64_t mem = 0, vmem = 0; |
189 | | -PROCESS_MEMORY_COUNTERS pmc; |
190 | | - |
191 | | -// get process hanlde by pid |
192 | | -HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid); |
193 | | -if (GetProcessMemoryInfo(process, &pmc, sizeof(pmc))) |
194 | | -{ |
195 | | - mem = pmc.WorkingSetSize; |
196 | | - vmem = pmc.PagefileUsage; |
197 | | -} |
198 | | -CloseHandle(process); |
199 | | - |
200 | | -// use GetCurrentProcess() can get current process and no need to close handle |
201 | | - |
202 | | -// convert mem from B to MB |
203 | | -return mem / 1024.0 / 1024.0; |
204 | | - |
205 | | -#else |
206 | | - char file_name[64] = { 0 }; |
207 | | - FILE* fd; |
208 | | - char line_buff[512] = { 0 }; |
209 | | - sprintf(file_name, "/proc/%d/status", pid); |
210 | | - |
211 | | - fd = fopen(file_name, "r"); |
212 | | - if (nullptr == fd) |
213 | | - return 0; |
214 | | - |
215 | | - char name[64]; |
216 | | - int vmrss = 0; |
217 | | - for (int i = 0; i < VMRSS_LINE - 1; i++) |
218 | | - fgets(line_buff, sizeof(line_buff), fd); |
219 | | - |
220 | | - fgets(line_buff, sizeof(line_buff), fd); |
221 | | - sscanf(line_buff, "%s %d", name, &vmrss); |
222 | | - fclose(fd); |
223 | | - |
224 | | - // cnvert VmRSS from KB to MB |
225 | | - return float(vmrss / 1024.0); |
226 | | -#endif |
227 | | -} |
228 | | - |
229 | | - |
230 | | - |
231 | | -template<> |
232 | | -template<> |
233 | | -void object::test<4> |
234 | | - () { |
235 | | - |
236 | | - index::strtree::SimpleSTRtree t(10); |
237 | | - std::vector<std::unique_ptr<geom::Geometry>> geoms; |
238 | | - const int gridSize = 100; |
239 | | - const int gap = 10; |
240 | | - auto gf = geom::GeometryFactory::create(); |
241 | | - |
242 | | - for (int i = 0; i < gridSize; ++i) { |
243 | | - for (int j = 0; j < gridSize; ++j) { |
244 | | - for (int k= 0; k < gridSize; ++k) { |
245 | | - geos::geom::Envelope3d e(i, i + gap, j, j + gap, k, k + gap); |
246 | | - const auto ep = &e; |
247 | | - t.insert(ep, static_cast<void*>(&e)); |
248 | | - } |
249 | | - } |
250 | | - } |
251 | | - t.getRoot3d(); |
252 | | - |
253 | | -} |
254 | 157 |
|
255 | 158 | } // namespace tut |
256 | 159 |
|
0 commit comments