gperftools cpp wrapper

// Compile command : ${CXX} -o test_profiler.elf -DUSE_GPERFTOOLS -DDEBUG -D_DEBUG ${CXXFLAGS} -O0 -g -Wall ${LIBS} -lprofiler ${BUILD_LDFLAGS} test_profiler.cpp
// Bash Command : kill -s SIGUSR1 <PID>
// CPU Profiler command : gperftools/bin/pprof -text test_profiler.elf test_profiler.prof
// see https://github.com/gperftools/gperftools/wiki

Source filename: test_profiler.cpp

  1. /* Start of test_profiler.cpp */
  2.  
  3. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  4. // Start of config_arch.h
  5.  
  6. #include <climits>
  7.  
  8. /* Whether or not the compiler supports long long and unsigned long long
  9. */
  10. #ifndef HAS_LONG_LONG
  11. #if __cplusplus >= 201103L
  12. #define HAS_LONG_LONG
  13. #else
  14. #ifdef __GNUG__
  15. #ifdef __SIZEOF_LONG_LONG__
  16. #define HAS_LONG_LONG
  17. #endif
  18. #endif
  19. #endif
  20. #endif
  21.  
  22. /* The character type that char matches (i.e., signed or unsigned)
  23. */
  24. #if CHAR_MIN < 0
  25. typedef signed char underlying_char_type;
  26. #else
  27. typedef unsigned char underlying_char_type;
  28. #endif
  29.  
  30. // End of config_arch.h
  31. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  32.  
  33. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  34. // Start of config_os.h
  35.  
  36. // =============================================================================
  37. // Determine the platform. Ex., Windows or POSIX. Define feature macros
  38.  
  39. #if ( defined( __unix__ ) || defined( __unix ) || ( defined( __APPLE__ ) && defined( __MACH__ ) ) )
  40. #include <unistd.h>
  41.  
  42. #ifdef _POSIX_VERSION
  43. // ISO POSIX.1 aka IEEE 1003.1
  44.  
  45. /// OS_POSIX - unistd.h is included and _POSIX_VERSION is defined
  46. #define OS_POSIX
  47.  
  48. #if _POSIX_VERSION >= 199506L
  49. // ISO POSIX.1-1996 aka IEEE 1003.1-1996
  50. #define POSIX_THREADS
  51.  
  52. #if ( _POSIX_VERSION >= 200112L )
  53. // ISO POSIX.1-2001 aka IEEE 1003.1-2001, aka Issue 6, aka SUSv3
  54. #define POSIX_ISSUE_6
  55.  
  56. #if ( _POSIX_VERSION >= 200809L )
  57. // ISO POSIX.1-2008, aka IEEE 1003.1-2008, aka Issue 7, aka SUSv4
  58. #define POSIX_ISSUE_7
  59. #endif //
  60. #endif //
  61. #endif //
  62. #endif // ifdef _POSIX_VERSION
  63. #endif // if ( defined( __unix__ ) || defined( __unix ) || ( defined( __APPLE__ ) && defined( __MACH__ )))
  64.  
  65. #if defined( _WIN64 ) || defined( _WIN32 )
  66. #include <windows.h> /* MS Windows operating systems */
  67. #define OS_WINDOWS
  68. #endif
  69.  
  70. // =============================================================================
  71. // Determine basic types
  72.  
  73. #ifdef OS_POSIX
  74. #include <sys/types.h>
  75. namespace stdbp
  76. {
  77. namespace os
  78. {
  79. // Identifies a user
  80. typedef uid_t user_id_type;
  81.  
  82. // Identifies a process
  83. typedef pid_t pid_type;
  84. }
  85. }
  86. #else
  87. #ifdef OS_WINDOWS
  88. namespace stdbp
  89. {
  90. namespace os
  91. {
  92. typedef DWORD pid_type;
  93. }
  94. }
  95. #endif // Windows
  96. #endif // ifdef OS_POSIX
  97.  
  98. // =============================================================================
  99. // Determine multithreading types
  100.  
  101. #ifdef POSIX_THREADS
  102. #include <pthread.h>
  103. namespace stdbp
  104. {
  105. namespace os
  106. {
  107. typedef pthread_t thread_type;
  108. typedef pthread_mutex_t mutex_type;
  109. typedef pthread_rwlock_t shared_mutex_type;
  110. typedef pthread_cond_t condition_variable_type;
  111. }
  112. }
  113. #else
  114. #ifdef OS_WINDOWS
  115. namespace stdbp
  116. {
  117. namespace os
  118. {
  119. typedef HANDLE thread_type;
  120. typedef CRITICAL_SECTION mutex_type;
  121. }
  122. }
  123. #endif
  124. #endif // ifdef POSIX_THREADS
  125.  
  126. // End of config_os.h
  127. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  128.  
  129. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  130. // Start of version.h
  131.  
  132. #include <cstddef>
  133.  
  134. #if __cplusplus >= 201703L
  135. #define CPP17
  136. #endif
  137. #if __cplusplus >= 201402L
  138. #define CPP14
  139. #endif
  140. #if __cplusplus >= 201103L
  141. #define CPP11
  142. #endif
  143.  
  144. #ifdef CPP17
  145. #define CPP17_NAMESPACE std
  146. #else
  147. #define CPP17_NAMESPACE cpp17
  148. #endif
  149.  
  150. #ifdef CPP14
  151. #define CPP14_NAMESPACE std
  152. #else
  153. #define CPP14_NAMESPACE cpp14
  154. #endif
  155.  
  156. #ifdef CPP11
  157. #define CPP11_NAMESPACE std
  158. #else
  159. #define CPP11_NAMESPACE cpp11
  160. #endif
  161.  
  162. namespace cpp11 {}
  163.  
  164. #ifndef CPP11
  165. namespace cpp11 {
  166.  
  167. class nullptr_t {
  168. public:
  169. nullptr_t() : _pad() {}
  170.  
  171. template< class T >
  172. operator T *() const { // 定义类型转换操作符,使nullptr_t 可转为任意非类成员指针类型。
  173. return ;
  174. }
  175.  
  176. template< class C, class T >
  177. operator T C::*() const { // 重载类型转换操作符,使 nullptr_t 可以转换为类 C 中任意的指针类型(数据成员指针/函数成员指针)。
  178. return ;
  179. }
  180. private:
  181. void *_pad; // std requires : sizeof(nullptr_t) == sizeof(void*)
  182. void operator &() const; // 不允许取地址操作。
  183. };
  184.  
  185. const nullptr_t nullptr; // 定义 nullptr_t 类型的变量 nullptr
  186.  
  187. } // namespace cpp11
  188.  
  189. #endif // #ifndef CPP11
  190.  
  191. namespace cpp14 {}
  192. namespace cpp17 {}
  193.  
  194. namespace cpp {
  195. using namespace ::std;
  196. using namespace ::CPP11_NAMESPACE;
  197. using namespace ::CPP14_NAMESPACE;
  198. using namespace ::CPP17_NAMESPACE;
  199. } // namespace cpp
  200.  
  201. // End of version.h
  202. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  203.  
  204. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  205. // Start of cstdint.h
  206.  
  207. #include <string>
  208. //#include "version.h"
  209.  
  210. #ifdef CPP11
  211. // Provided by C++11
  212. #include <cstdint>
  213. #else
  214.  
  215. #include <climits>
  216.  
  217. // Steal some types from the implementation, if we can
  218. #if !defined( _WIN32 ) && ( defined( __unix__ ) || defined( __unix ) || ( defined( __APPLE__ ) && defined( __MACH__ )))
  219. #include <unistd.h>
  220. #if ( _POSIX_C_SOURCE >= 200112L )
  221. // Provided by POSIX
  222. #include <stdint.h>
  223.  
  224. namespace cpp11 {
  225. using ::intptr_t;
  226. using ::uintptr_t;
  227. }
  228. #endif // POSIX
  229. #endif // UNIX-LIKE
  230.  
  231. namespace cpp11 {
  232. #define AT_LEAST_16_BITS_S(x) ((x) >= 32767)
  233. #define AT_LEAST_32_BITS_S(x) ((x) >= 2147483647)
  234. #define AT_LEAST_64_BITS_S(x) ((((((x) >> 15) >> 15) >> 15) >> 15) >= 7)
  235. #define AT_LEAST_16_BITS_U(x) ((x) >= 65535)
  236. #define AT_LEAST_32_BITS_U(x) (((x) >> 1) >= 2147483647)
  237. #define AT_LEAST_64_BITS_U(x) ((((((x) >> 15) >> 15) >> 15) >> 15) >= 15)
  238.  
  239. #define EXACTLY_8_BITS_S(x) ((x) == 127)
  240. #define EXACTLY_16_BITS_S(x) ((x) == 32767)
  241. #define EXACTLY_32_BITS_S(x) ((x) == 2147483647)
  242. #define EXACTLY_64_BITS_S(x) ((((((x) >> 15) >> 15) >> 15) >> 15) == 7)
  243. #define EXACTLY_8_BITS_U(x) ((x) == 255)
  244. #define EXACTLY_16_BITS_U(x) ((x) == 65535)
  245. #define EXACTLY_32_BITS_U(x) (((x) >> 1) == 2147483647)
  246. #define EXACTLY_64_BITS_U(x) ((((((x) >> 15) >> 15) >> 15) >> 15) == 15)
  247.  
  248. // int_least8_t
  249. typedef signed char int_least8_t;
  250. #ifndef INT8_C
  251. #define INT8_C(x) x
  252. #endif
  253. #ifndef INT_LEAST8_MIN
  254. #define INT_LEAST8_MIN SCHAR_MIN
  255. #endif
  256. #ifndef INT_LEAST8_MAX
  257. #define INT_LEAST8_MAX SCHAR_MAX
  258. #endif
  259.  
  260. // int8_t
  261. #if EXACTLY_8_BITS_S(INT_LEAST8_MAX)
  262. #ifndef INT8_MIN
  263. #define INT8_MIN INT_LEAST8_MIN
  264. #endif
  265. #ifndef INT8_MAX
  266. #define INT8_MAX INT_LEAST8_MAX
  267. #endif
  268. typedef int_least8_t int8_t;
  269. #endif
  270.  
  271. // int_least16_t
  272. #if AT_LEAST_16_BITS_S(SCHAR_MAX)
  273. typedef signed char int_least16_t;
  274. #ifndef INT_LEAST16_MIN
  275. #define INT_LEAST16_MIN SCHAR_MIN
  276. #endif
  277. #ifndef INT_LEAST16_MAX
  278. #define INT_LEAST16_MAX SCHAR_MAX
  279. #endif
  280. #else
  281. typedef short int int_least16_t;
  282. #ifndef INT_LEAST16_MIN
  283. #define INT_LEAST16_MIN SHRT_MIN
  284. #endif
  285. #ifndef INT_LEAST16_MAX
  286. #define INT_LEAST16_MAX SHRT_MAX
  287. #endif
  288. #endif
  289. #ifndef INT16_C
  290. #define INT16_C(x) x
  291. #endif
  292.  
  293. // int16_t
  294. #if EXACTLY_16_BITS_S(INT_LEAST8_MAX)
  295. #ifndef INT16_MIN
  296. #define INT16_MIN INT_LEAST16_MIN
  297. #endif
  298. #ifndef INT16_MAX
  299. #define INT16_MAX INT_LEAST16_MAX
  300. #endif
  301. typedef int_least16_t int16_t;
  302. #endif
  303.  
  304. // int_least32_t
  305. #if AT_LEAST_32_BITS_S(SCHAR_MAX)
  306. typedef signed char int_least32_t
  307. #ifndef INT_LEAST32_MIN
  308. #define INT_LEAST32_MIN SCHAR_MIN
  309. #endif
  310. #ifndef INT_LEAST32_MAX
  311. #define INT_LEAST32_MAX SCHAR_MAX
  312. #endif
  313. #ifndef INT32_C
  314. #define INT32_C(x) x
  315. #endif
  316. #elif AT_LEAST_32_BITS_S(SHRT_MAX)
  317. typedef short int int_least32_t
  318. #ifndef INT_LEAST32_MIN
  319. #define INT_LEAST32_MIN SHRT_MIN
  320. #endif
  321. #ifndef INT_LEAST32_MAX
  322. #define INT_LEAST32_MAX SHRT_MAX
  323. #endif
  324. #ifndef INT32_C
  325. #define INT32_C(x) x
  326. #endif
  327. #elif AT_LEAST_32_BITS_S(INT_MAX)
  328. typedef int int_least32_t;
  329. #ifndef INT_LEAST32_MIN
  330. #define INT_LEAST32_MIN INT_MIN
  331. #endif
  332. #ifndef INT_LEAST32_MAX
  333. #define INT_LEAST32_MAX INT_MAX
  334. #endif
  335. #ifndef INT32_C
  336. #define INT32_C(x) x
  337. #endif
  338. #else
  339. typedef long int_least32_t;
  340. #ifndef INT_LEAST32_MIN
  341. #define INT_LEAST32_MIN LONG_MIN
  342. #endif
  343. #ifndef INT_LEAST32_MAX
  344. #define INT_LEAST32_MAX LONG_MAX
  345. #endif
  346. #ifndef INT32_C
  347. #define INT32_C(x) x##l
  348. #endif
  349. #endif // if AT_LEAST_32_BITS_S(SCHAR_MAX)
  350.  
  351. // int32_t
  352. #if EXACTLY_32_BITS_S(INT_LEAST32_MAX)
  353. #ifndef INT32_MIN
  354. #define INT32_MIN INT_LEAST32_MIN
  355. #endif
  356. #ifndef INT32_MAX
  357. #define INT32_MAX INT_LEAST32_MAX
  358. #endif
  359. typedef int_least32_t int32_t;
  360. #endif
  361.  
  362. // int_least64_t
  363. #if AT_LEAST_64_BITS_S(SCHAR_MAX)
  364. typedef signed char int_least64_t
  365. #ifndef INT_LEAST64_MIN
  366. #define INT_LEAST64_MIN SCHAR_MIN
  367. #endif
  368. #ifndef INT_LEAST64_MAX
  369. #define INT_LEAST64_MAX SCHAR_MAX
  370. #endif
  371. #ifndef INT64_C
  372. #define INT64_C(x) x
  373. #endif
  374. #elif AT_LEAST_64_BITS_S(SHRT_MAX)
  375. typedef short int_least64_t
  376. #ifndef INT_LEAST64_MIN
  377. #define INT_LEAST64_MIN SHRT_MIN
  378. #endif
  379. #ifndef INT_LEAST64_MAX
  380. #define INT_LEAST64_MAX SHRT_MAX
  381. #endif
  382. #ifndef INT64_C
  383. #define INT64_C(x) x
  384. #endif
  385. #elif AT_LEAST_64_BITS_S(INT_MAX)
  386. typedef int int_least64_t;
  387. #ifndef INT_LEAST64_MIN
  388. #define INT_LEAST64_MIN INT_MIN
  389. #endif
  390. #ifndef INT_LEAST64_MAX
  391. #define INT_LEAST64_MAX INT_MAX
  392. #endif
  393. #ifndef INT64_C
  394. #define INT64_C(x) x
  395. #endif
  396. #elif AT_LEAST_64_BITS_S(LONG_MAX)
  397. typedef long int_least64_t;
  398. #ifndef INT_LEAST64_MIN
  399. #define INT_LEAST64_MIN LONG_MIN
  400. #endif
  401. #ifndef INT_LEAST64_MAX
  402. #define INT_LEAST64_MAX LONG_MAX
  403. #endif
  404. #ifndef INT64_C
  405. #define INT64_C(x) x##l
  406. #endif
  407. #else
  408. #ifdef LLONG_MAX
  409. typedef long long int_least64_t;
  410. #ifndef INT_LEAST64_MIN
  411. #define INT_LEAST64_MIN LLONG_MIN
  412. #endif
  413. #ifndef INT_LEAST64_MAX
  414. #define INT_LEAST64_MAX LLONG_MAX
  415. #endif
  416. #ifndef INT64_C
  417. #define INT64_C(x) x##ll
  418. #endif
  419. #endif
  420. #endif // if AT_LEAST_64_BITS_S(SCHAR_MAX)
  421.  
  422. // int64_t
  423. #if EXACTLY_64_BITS_S(INT_LEAST64_MAX)
  424. #ifndef INT64_MIN
  425. #define INT64_MIN INT_LEAST64_MIN
  426. #endif
  427. #ifndef INT64_MAX
  428. #define INT64_MAX INT_LEAST64_MAX
  429. #endif
  430. typedef int_least64_t int64_t;
  431. #endif
  432.  
  433. // uint_least8_t
  434. typedef unsigned char uint_least8_t;
  435. #ifndef UINT8_C
  436. #define UINT8_C(x) x
  437. #endif
  438. #ifndef UINT_LEAST8_MAX
  439. #define UINT_LEAST8_MAX UCHAR_MAX
  440. #endif
  441.  
  442. // uint8_t
  443. #if EXACTLY_8_BITS_U(UINT_LEAST8_MAX)
  444. #ifndef UINT8_MAX
  445. #define UINT8_MAX UINT_LEAST8_MAX
  446. #endif
  447. typedef uint_least8_t uint8_t;
  448. #endif
  449.  
  450. // uint_least16_t
  451. #if AT_LEAST_16_BITS_U(UCHAR_MAX)
  452. typedef unsigned char uint_least16_t;
  453. #ifndef UINT_LEAST16_MAX
  454. #define UINT_LEAST16_MAX UCHAR_MAX
  455. #endif
  456. #else
  457. typedef unsigned short uint_least16_t;
  458. #ifndef UINT_LEAST16_MAX
  459. #define UINT_LEAST16_MAX USHRT_MAX
  460. #endif
  461. #endif
  462. #ifndef UINT16_C
  463. #define UINT16_C(x) x
  464. #endif
  465.  
  466. // uint16_t
  467. #if EXACTLY_16_BITS_U(UINT_LEAST16_MAX)
  468. #ifndef UINT16_MAX
  469. #define UINT16_MAX UINT_LEAST16_MAX
  470. #endif
  471. typedef uint_least16_t uint16_t;
  472. #endif
  473.  
  474. // uint_least32_t
  475. #if AT_LEAST_32_BITS_U(UCHAR_MAX)
  476. typedef unsigned char uint_least32_t
  477. #ifndef UINT_LEAST32_MAX
  478. #define UINT_LEAST32_MAX UCHAR_MAX
  479. #endif
  480. #ifndef UINT32_C
  481. #define UINT32_C(x) x
  482. #endif
  483. #elif AT_LEAST_32_BITS_U(USHRT_MAX)
  484. typedef unsigned short uint_least32_t
  485. #ifndef UINT_LEAST32_MAX
  486. #define UINT_LEAST32_MAX USHRT_MAX
  487. #endif
  488. #ifndef UINT32_C
  489. #define UINT32_C(x) x
  490. #endif
  491. #elif AT_LEAST_32_BITS_U(UINT_MAX)
  492. typedef unsigned uint_least32_t;
  493. #ifndef UINT_LEAST32_MAX
  494. #define UINT_LEAST32_MAX UINT_MAX
  495. #endif
  496. #ifndef UINT32_C
  497. #define UINT32_C(x) x
  498. #endif
  499. #else
  500. typedef unsigned long uint_least32_t;
  501. #ifndef UINT_LEAST32_MAX
  502. #define UINT_LEAST32_MAX ULONG_MAX
  503. #endif
  504. #ifndef UINT32_C
  505. #define UINT32_C(x) x##ul
  506. #endif
  507. #endif // if AT_LEAST_32_BITS_U(UCHAR_MAX)
  508.  
  509. // uint32_t
  510. #if EXACTLY_32_BITS_U(UINT_LEAST32_MAX)
  511. #ifndef UINT32_MAX
  512. #define UINT32_MAX UINT_LEAST32_MAX
  513. #endif
  514. typedef uint_least32_t uint32_t;
  515. #endif
  516.  
  517. // uint_least64_t
  518. #if AT_LEAST_64_BITS_U(UCHAR_MAX)
  519. typedef unsigned char uint_least64_t
  520. #ifndef UINT64_C
  521. #define UINT64_C(x) x
  522. #endif
  523. #ifndef UINT_LEAST64_MAX
  524. #define UINT_LEAST64_MAX UCHAR_MAX
  525. #endif
  526. #elif AT_LEAST_64_BITS_U(USHRT_MAX)
  527. typedef unsigned short uint_least64_t
  528. #ifndef UINT64_C
  529. #define UINT64_C(x) x
  530. #endif
  531. #ifndef UINT_LEAST64_MAX
  532. #define UINT_LEAST64_MAX USHRT_MAX
  533. #endif
  534. #elif AT_LEAST_64_BITS_U(UINT_MAX)
  535. typedef unsigned uint_least64_t;
  536. #ifndef UINT64_C
  537. #define UINT64_C(x) x
  538. #endif
  539. #ifndef UINT_LEAST64_MAX
  540. #define UINT_LEAST64_MAX UINT_MAX
  541. #endif
  542. #elif AT_LEAST_64_BITS_U(LONG_MAX)
  543. typedef unsigned long uint_least64_t;
  544. #ifndef UINT64_C
  545. #define UINT64_C(x) x##ul
  546. #endif
  547. #ifndef UINT_LEAST64_MAX
  548. #define UINT_LEAST64_MAX ULONG_MAX
  549. #endif
  550. #else
  551. #ifdef ULLONG_MAX
  552. typedef unsigned long long uint_least64_t;
  553. #ifndef UINT64_C
  554. #define UINT64_C(x) x##ull
  555. #endif
  556. #ifndef UINT_LEAST64_MAX
  557. #define UINT_LEAST64_MAX ULLONG_MAX
  558. #endif
  559. #endif
  560. #endif // if AT_LEAST_64_BITS_U(UCHAR_MAX)
  561.  
  562. // uint64_t
  563. #if EXACTLY_64_BITS_U(UINT_LEAST64_MAX)
  564. #ifndef UINT64_MAX
  565. #define UINT64_MAX UINT_LEAST64_MAX
  566. #endif
  567. typedef uint_least64_t uint64_t;
  568. #endif
  569.  
  570. typedef signed char int_fast8_t;
  571. typedef int int_fast16_t;
  572. typedef long int_fast32_t;
  573. typedef int_least64_t int_fast64_t;
  574.  
  575. typedef unsigned char uint_fast8_t;
  576. typedef unsigned uint_fast16_t;
  577. typedef unsigned long uint_fast32_t;
  578. typedef uint_least64_t uint_fast64_t;
  579.  
  580. #ifdef LLONG_MAX
  581. typedef long long intmax_t;
  582. #ifndef INTMAX_C
  583. #define INTMAX_C(x) x##ll
  584. #endif
  585. #ifndef INTMAX_MAX
  586. #define INTMAX_MAX LLONG_MAX
  587. #endif
  588. #else
  589. typedef long intmax_t;
  590. #ifndef INTMAX_C
  591. #define INTMAX_C(x) x##l
  592. #endif
  593. #ifndef INTMAX_MAX
  594. #define INTMAX_MAX LONG_MAX
  595. #endif
  596. #endif
  597.  
  598. #ifdef ULLONG_MAX
  599. typedef unsigned long long uintmax_t;
  600. #ifndef UINTMAX_C
  601. #define UINTMAX_C(x) x##ull
  602. #endif
  603. #ifndef UINTMAX_MAX
  604. #define UINTMAX_MAX ULLONG_MAX
  605. #endif
  606. #else
  607. typedef unsigned long uintmax_t;
  608. #ifndef UINTMAX_C
  609. #define UINTMAX_C(x) x##ul
  610. #endif
  611. #ifndef UINTMAX_MAX
  612. #define UINTMAX_MAX ULONG_MAX
  613. #endif
  614. #endif
  615.  
  616. #undef EXACTLY_8_BITS_S
  617. #undef EXACTLY_16_BITS_S
  618. #undef EXACTLY_32_BITS_S
  619. #undef EXACTLY_64_BITS_S
  620. #undef EXACTLY_8_BITS_U
  621. #undef EXACTLY_16_BITS_U
  622. #undef EXACTLY_32_BITS_U
  623. #undef EXACTLY_64_BITS_U
  624.  
  625. #undef AT_LEAST_16_BITS_S
  626. #undef AT_LEAST_32_BITS_S
  627. #undef AT_LEAST_64_BITS_S
  628. #undef AT_LEAST_16_BITS_U
  629. #undef AT_LEAST_32_BITS_U
  630. #undef AT_LEAST_64_BITS_U
  631. } // namespace cpp11
  632.  
  633. #endif // #ifdef CPP11
  634.  
  635. // End of cstdint.h
  636. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  637.  
  638. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  639. // Start of string.h
  640.  
  641. #include <string>
  642. //#include "version.h"
  643.  
  644. #ifndef CPP11
  645. #include <cstdlib>
  646. #include <iostream>
  647. #include <sstream>
  648. //#include "config_arch.h"
  649. namespace cpp11 {
  650. namespace detail {
  651. template< typename I >
  652. std::string arithmetic_to_string(I x) {
  653. std::ostringstream ss;
  654. ss << x;
  655. return ss.str();
  656. }
  657.  
  658. template< typename I >
  659. std::wstring arithmetic_to_wstring(I x) {
  660. std::wostringstream ss;
  661. ss << x;
  662. return ss.str();
  663. }
  664. } // namespace detail
  665.  
  666. inline unsigned long stoul(
  667. const std::string &s,
  668. std::size_t *pos = ,
  669. int base = ) {
  670. char *ptr;
  671. const char *s_ = s.c_str();
  672. const long res = std::strtoul(s_, &ptr, base);
  673. if (pos) {
  674. *pos = ptr - s_;
  675. }
  676. return res;
  677. }
  678.  
  679. /// @todo Should throw if not convertible, or result is too large
  680. inline long stol(
  681. const std::string &s,
  682. std::size_t *pos = ,
  683. int base = ) {
  684. char * ptr;
  685. const char *s_ = s.c_str();
  686. const long res = std::strtol(s_, &ptr, base);
  687. if (pos) {
  688. *pos = ptr - s_;
  689. }
  690. return res;
  691. }
  692.  
  693. /// @todo Should throw if not convertible, or result is too large
  694. inline int stoi(
  695. const std::string &s,
  696. std::size_t *pos = ,
  697. int base = ) {
  698. return static_cast< int >(stol(s, pos, base));
  699. }
  700.  
  701. /** @brief Get the string representation of an int
  702. * @param n An integer
  703. * @returns lexical_cast<std::string>(n)
  704. */
  705. inline std::string to_string(int n) {
  706. return detail::arithmetic_to_string(n);
  707. }
  708.  
  709. inline std::string to_string(long n) {
  710. return detail::arithmetic_to_string(n);
  711. }
  712.  
  713. inline std::string to_string(unsigned n) {
  714. return detail::arithmetic_to_string(n);
  715. }
  716.  
  717. inline std::string to_string(unsigned long n) {
  718. return detail::arithmetic_to_string(n);
  719. }
  720.  
  721. #ifdef HAS_LONG_LONG
  722. inline std::string to_string(long long n) {
  723. return detail::arithmetic_to_string(n);
  724. }
  725.  
  726. inline std::string to_string(unsigned long long n) {
  727. return detail::arithmetic_to_string(n);
  728. }
  729. #endif // #ifdef HAS_LONG_LONG
  730.  
  731. inline std::string to_string(float n) {
  732. return detail::arithmetic_to_string(n);
  733. }
  734.  
  735. inline std::string to_string(double n) {
  736. return detail::arithmetic_to_string(n);
  737. }
  738.  
  739. inline std::string to_string(long double n) {
  740. return detail::arithmetic_to_string(n);
  741. }
  742.  
  743. inline std::wstring to_wstring(int n) {
  744. return detail::arithmetic_to_wstring(n);
  745. }
  746.  
  747. inline std::wstring to_wstring(unsigned n) {
  748. return detail::arithmetic_to_wstring(n);
  749. }
  750.  
  751. inline std::wstring to_wstring(long n) {
  752. return detail::arithmetic_to_wstring(n);
  753. }
  754.  
  755. inline std::wstring to_wstring(unsigned long n) {
  756. return detail::arithmetic_to_wstring(n);
  757. }
  758.  
  759. #ifdef HAS_LONG_LONG
  760. inline std::wstring to_wstring(long long n) {
  761. return detail::arithmetic_to_wstring(n);
  762. }
  763.  
  764. inline std::wstring to_wstring(unsigned long long n) {
  765. return detail::arithmetic_to_wstring(n);
  766. }
  767. #endif // #ifdef HAS_LONG_LONG
  768.  
  769. inline std::wstring to_wstring(float n) {
  770. return detail::arithmetic_to_wstring(n);
  771. }
  772.  
  773. inline std::wstring to_wstring(double n) {
  774. return detail::arithmetic_to_wstring(n);
  775. }
  776.  
  777. inline std::wstring to_wstring(long double n) {
  778. return detail::arithmetic_to_wstring(n);
  779. }
  780.  
  781. } // namespace cpp11
  782. #endif // #ifndef CPP11
  783.  
  784. // End of string.h
  785. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  786.  
  787. //#include "version.h"
  788. //#include "config_arch.h"
  789. //#include "config_os.h"
  790. //#include "cstdint.h"
  791. //#include "string.h.h"
  792.  
  793. #include <cstdio>
  794. #include <cstdlib>
  795. #include <cerrno>
  796. #include <csignal>
  797. #include <ctime>
  798. #include <cstring>
  799. #include <sstream>
  800.  
  801. namespace lse_ns_util {
  802.  
  803. namespace common {
  804.  
  805. char *GetFilename(const char *fullname) {
  806. char *name = cpp::nullptr;
  807. #if ( defined( __unix__ ) || defined( __unix ) || ( defined( __APPLE__ ) && defined( __MACH__ ) ) )
  808. const char splitchar = '/';
  809. #elif defined( _WIN64 ) || defined( _WIN32 )
  810. const char splitchar = '\\';
  811. #else
  812. const char splitchar = '\ ';
  813. #endif
  814. if (fullname == cpp::nullptr || *fullname == '\0') {
  815. return cpp::nullptr;
  816. }
  817.  
  818. for (char *ptr = (char *)fullname; *ptr != '\0'; ptr++) {
  819. if (*ptr == splitchar && *(ptr + ) != '\0') {
  820. name = ptr;
  821. }
  822. }
  823.  
  824. // eg: fullname == "/"
  825. if (name == cpp::nullptr && *fullname == splitchar) {
  826. return cpp::nullptr;
  827. }
  828. // eg: fullname == "xxx.elf/"
  829. if (name == cpp::nullptr && (*(fullname + strlen(fullname) - ) == splitchar) ) {
  830. return cpp::nullptr;
  831. }
  832. // eg: fullname == "/yyy/xxx.elf/"
  833. if (name != cpp::nullptr && (*(fullname + strlen(fullname) - ) == splitchar)) {
  834. return cpp::nullptr;
  835. }
  836. // eg: fullname == "xxx.elf"
  837. if (name == cpp::nullptr && *fullname != splitchar) {
  838. return (char *)fullname;
  839. }
  840. // eg: fullname == "/xxx.elf"
  841. if ((name != cpp::nullptr && name == fullname)) {
  842. return (name + );
  843. }
  844. // eg: fullname == "/yyy/xxx.elf"
  845. if (name != cpp::nullptr && name != fullname) {
  846. return (name + );
  847. }
  848.  
  849. return cpp::nullptr;
  850. }
  851.  
  852. size_t GetPathname(const char *fullname, char *pathname, const size_t pathszie) {
  853. char *name = cpp::nullptr;
  854. #if ( defined( __unix__ ) || defined( __unix ) || ( defined( __APPLE__ ) && defined( __MACH__ ) ) )
  855. const char splitchar = '/';
  856. const char *splitstr = "/";
  857. #elif defined( _WIN64 ) || defined( _WIN32 )
  858. const char splitchar = '\\';
  859. const char *splitstr = "\\";
  860. #else
  861. const char splitchar = '\ ';
  862. const char *splitstr = "\ ";
  863. #endif
  864. if (fullname == cpp::nullptr || *fullname == '\0' || pathname == cpp::nullptr || pathszie < ) {
  865. return ;
  866. }
  867.  
  868. for (char *ptr = (char *)fullname; *ptr != '\0'; ptr++) {
  869. if (*ptr == splitchar && *(ptr + ) != '\0') {
  870. name = ptr;
  871. }
  872. }
  873.  
  874. // eg: fullname == "/"
  875. if (name == cpp::nullptr && *fullname == splitchar) {
  876. strncpy(pathname, splitstr, strlen(splitstr));
  877. return strlen(pathname);
  878. }
  879. // eg: fullname == "xxx.elf/"
  880. if (name == cpp::nullptr && (*(fullname + strlen(fullname) - ) == splitchar)) {
  881. strncpy(pathname, ".", strlen("."));
  882. return strlen(pathname);
  883. }
  884. // eg: fullname == "/yyy/xxx.elf/"
  885. if (name != cpp::nullptr && (*(fullname + strlen(fullname) - ) == splitchar)) {
  886. if (pathszie > (size_t)(name - fullname)) {
  887. strncpy(pathname, fullname, (size_t)(name - fullname));
  888. return strlen(pathname);
  889. }
  890. else {
  891. return ;
  892. }
  893. }
  894. // eg: fullname == "xxx.elf"
  895. if (name == cpp::nullptr && *fullname != splitchar) {
  896. strncpy(pathname, ".", strlen("."));
  897. return strlen(pathname);
  898. }
  899. // eg: fullname == "/xxx.elf"
  900. if ((name != cpp::nullptr && name == fullname)) {
  901. strncpy(pathname, splitstr, strlen(splitstr));
  902. return strlen(pathname);
  903. }
  904. // eg: fullname == "/yyy/xxx.elf"
  905. if (name != cpp::nullptr && name != fullname) {
  906. if (pathszie > (size_t)(name - fullname)) {
  907. strncpy(pathname, fullname, (size_t)(name - fullname));
  908. return strlen(pathname);
  909. }
  910. else {
  911. return ;
  912. }
  913. }
  914.  
  915. return ;
  916. }
  917.  
  918. size_t DelLastSuffix(const char *filename, const char splitchar, char *newname, const size_t newszie) {
  919. char *name = cpp::nullptr;
  920. const char splitstr[] = { splitchar, '\0' };
  921.  
  922. if (filename == cpp::nullptr || *filename == '\0' || newname == cpp::nullptr || newszie < ) {
  923. return ;
  924. }
  925.  
  926. for (char *ptr = (char *)filename; *ptr != '\0'; ptr++)
  927. {
  928. if (*ptr == splitchar && *(ptr + ) != '\0') {
  929. name = ptr;
  930. }
  931. }
  932.  
  933. // eg: filename == "."
  934. if (name == cpp::nullptr && *filename == splitchar) {
  935. strncpy(newname, splitstr, strlen(splitstr));
  936. return strlen(newname);
  937. }
  938. // eg; filename == "xxx."
  939. if (name == cpp::nullptr && (*(filename + strlen(filename) - ) == splitchar)) {
  940. if (newszie > strlen(filename) - ) {
  941. strncpy(newname, filename, strlen(filename) - );
  942. return strlen(newname);
  943. }
  944. else {
  945. return ;
  946. }
  947. }
  948. // eg; filename == "yyy.xxx."
  949. if (name != cpp::nullptr && (*(filename + strlen(filename) - ) == splitchar)) {
  950. if (newszie > (size_t)(name - filename)) {
  951. strncpy(newname, filename, (size_t)(name - filename));
  952. return strlen(newname);
  953. }
  954. else {
  955. return ;
  956. }
  957. }
  958. // eg: filename == "xxx"
  959. if (name == cpp::nullptr && *filename != splitchar) {
  960. if (newszie > strlen(filename)) {
  961. strncpy(newname, filename, strlen(filename));
  962. return strlen(newname);
  963. }
  964. else {
  965. return ;
  966. }
  967. }
  968. // eg: filename == ".xxx"
  969. if ((name != cpp::nullptr && name == filename)) {
  970. strncpy(newname, splitstr, strlen(splitstr));
  971. return strlen(newname);
  972. }
  973. // eg: filename == "xxx.yyy.zzz"
  974. if (name != cpp::nullptr && name != filename) {
  975. if (newszie > (size_t)(name - filename)) {
  976. strncpy(newname, filename, (size_t)(name - filename));
  977. return strlen(newname);
  978. }
  979. else {
  980. return ;
  981. }
  982. }
  983.  
  984. return ;
  985. }
  986.  
  987. int setupSignal(int signum, void(*handler) (int)) {
  988. const size_t MAX_BUF_LEN = ;
  989. char strbuf[MAX_BUF_LEN] = {'\0'};
  990. struct sigaction s_sigAction;
  991. s_sigAction.sa_handler = handler;
  992. s_sigAction.sa_flags = ;
  993. sigemptyset(&s_sigAction.sa_mask);
  994. sigaddset(&s_sigAction.sa_mask, signum);
  995. if (sigaction(signum, &s_sigAction, cpp::nullptr) < ) {
  996. strerror_r(errno, strbuf, MAX_BUF_LEN);
  997. fprintf(stderr, "error: %d - %s", errno, strbuf);
  998. return errno;
  999. }
  1000. else {
  1001. return ;
  1002. }
  1003. }
  1004.  
  1005. std::string TimeToTimestampStr(time_t t) {
  1006. tm dTm;
  1007. tm* aTm = localtime_r(&t, &dTm);
  1008. const size_t MAX_BUF_LEN = ;
  1009. char strbuf[MAX_BUF_LEN] = { '\0' };
  1010. // YYYY year
  1011. // MM month (2 digits 01-12)
  1012. // DD day (2 digits 01-31)
  1013. // HH hour (2 digits 00-23)
  1014. // MM minutes (2 digits 00-59)
  1015. // SS seconds (2 digits 00-59)
  1016. snprintf(strbuf, MAX_BUF_LEN, "%04d-%02d-%02d_%02d:%02d:%02d", aTm->tm_year + , aTm->tm_mon + , aTm->tm_mday, aTm->tm_hour, aTm->tm_min, aTm->tm_sec);
  1017. return std::string(strbuf);
  1018. }
  1019.  
  1020. uint32_t CreatePIDFile(std::string filename) {
  1021. FILE * pid_file = fopen(filename.c_str(), "w");
  1022. if (pid_file == cpp::nullptr) {
  1023. return ;
  1024. }
  1025.  
  1026. #ifdef WIN32
  1027. DWORD pid = GetCurrentProcessId();
  1028. #else
  1029. pid_t pid = getpid();
  1030. #endif
  1031.  
  1032. fprintf(pid_file, "%d", pid);
  1033. fclose(pid_file);
  1034.  
  1035. return (uint32_t)pid;
  1036. }
  1037.  
  1038. }
  1039.  
  1040. namespace prof {
  1041.  
  1042. #if (defined(__linux__) || defined(__FreeBSD__)) && defined(USE_GPERFTOOLS)
  1043. #include <gperftools/profiler.h>
  1044. #endif
  1045.  
  1046. class Profiler {
  1047. public:
  1048. static Profiler *getInstance() {
  1049. return instance;
  1050. }
  1051.  
  1052. static Profiler *FreeInstance() {
  1053. if (instance != cpp::nullptr) {
  1054. delete instance;
  1055. instance = cpp::nullptr;
  1056. }
  1057. return instance;
  1058. }
  1059.  
  1060. bool IsRunning() const {
  1061. #if (defined(__linux__) || defined(__FreeBSD__)) && defined(USE_GPERFTOOLS)
  1062. ProfilerState state;
  1063. ProfilerGetCurrentState(&state);
  1064. return state.enabled;
  1065. #else
  1066. return false;
  1067. #endif
  1068. }
  1069.  
  1070. void Flush() {
  1071. #if (defined(__linux__) || defined(__FreeBSD__)) && defined(USE_GPERFTOOLS)
  1072. ProfilerFlush();
  1073. #endif
  1074. }
  1075.  
  1076. void RegisterThread() {
  1077. #if (defined(__linux__) || defined(__FreeBSD__)) && defined(USE_GPERFTOOLS)
  1078. ProfilerRegisterThread();
  1079. #endif
  1080. }
  1081.  
  1082. bool Start(std::string filename, std::string &failureReason) {
  1083. #if (defined(__linux__) || defined(__FreeBSD__)) && defined(USE_GPERFTOOLS)
  1084. if (IsRunning()) {
  1085. failureReason = "Already running";
  1086. return false;
  1087. }
  1088.  
  1089. if (ProfilerStart(filename.c_str()) == ) {
  1090. failureReason = "ProfilerStart returned an error";
  1091. return false;
  1092. }
  1093.  
  1094. return true;
  1095. #else
  1096. failureReason = "Not compiled with gperftools";
  1097. return false;
  1098. #endif
  1099. }
  1100. bool Stop(std::string &failureReason) {
  1101. #if (defined(__linux__) || defined(__FreeBSD__)) && defined(USE_GPERFTOOLS)
  1102. if (!IsRunning()) {
  1103. failureReason = "Not running";
  1104. return false;
  1105. }
  1106. ProfilerStop();
  1107. return true;
  1108. #else
  1109. failureReason = "Not compiled with gperftools";
  1110. return false;
  1111. #endif
  1112. }
  1113.  
  1114. std::string GetInfos() const {
  1115. #if (defined(__linux__) || defined(__FreeBSD__)) && defined(USE_GPERFTOOLS)
  1116. bool enabledForAllThreads = ProfilingIsEnabledForAllThreads();
  1117. ProfilerState state;
  1118. ProfilerGetCurrentState(&state);
  1119.  
  1120. std::stringstream infos;
  1121. infos.str("");
  1122. infos.clear();
  1123.  
  1124. infos << "Profiling is " << std::endl;
  1125. infos << "- " << (state.enabled ? "enabled" : "disabled") << std::endl;
  1126. if (!IsRunning()) {
  1127. return infos.str();
  1128. }
  1129.  
  1130. infos << "- " << (enabledForAllThreads ? "" : "not ") << "enabled for all threads" << std::endl;
  1131. infos << "- Started at timestamp(" << cpp::to_string(state.start_time) << ") / localtime(" << ::lse_ns_util::common::TimeToTimestampStr(state.start_time) << ")" << std::endl;
  1132. infos << "- Writing to filename(" << state.profile_name << ")" << std::endl;
  1133. infos << "- Has currently gathered " << cpp::to_string(state.samples_gathered) << " samples" << std::endl;
  1134. return infos.str();
  1135. #else
  1136. return "Not compiled with gperftools";
  1137. #endif
  1138. }
  1139.  
  1140. private:
  1141. static Profiler *instance; // 声明的静态成员变量 instance
  1142. Profiler() {}
  1143. };
  1144. // 定义 Profiler 类的静态成员变量 instance
  1145. Profiler *Profiler::instance = new Profiler();
  1146.  
  1147. } // namespace prof
  1148.  
  1149. namespace util {
  1150. using namespace ::lse_ns_util::common;
  1151. using namespace ::lse_ns_util::prof;
  1152. }
  1153.  
  1154. } // namespace lse_ns_util
  1155.  
  1156. #include <csignal>
  1157. #include <iostream>
  1158.  
  1159. void profilerSignalHandler(int signum) {
  1160. static bool isRunning = false;
  1161.  
  1162. if (signum != SIGUSR1) {
  1163. return;
  1164. }
  1165.  
  1166. const char *profilerDefaultname = "test";
  1167. const char *profilerSuffix = ".prof";
  1168. const size_t MAX_FILENAME_LEN = ;
  1169. char profilerFilename[MAX_FILENAME_LEN] = { '\0' };
  1170. std::string strTemp;
  1171. std::string strFilename;
  1172.  
  1173. strFilename.erase();
  1174. strFilename.clear();
  1175. if (lse_ns_util::util::DelLastSuffix(lse_ns_util::util::GetFilename(__FILE__), '.', profilerFilename, MAX_FILENAME_LEN) != ) {
  1176. strFilename.append(profilerFilename).append(profilerSuffix);
  1177. }
  1178. else {
  1179. strFilename.append(profilerDefaultname).append(profilerSuffix);
  1180. }
  1181.  
  1182. strTemp.erase();
  1183. strTemp.clear();
  1184. lse_ns_util::util::Profiler * profiler = lse_ns_util::util::Profiler::getInstance();
  1185. isRunning = profiler->IsRunning();
  1186. if (!isRunning) {
  1187. profiler->Start(strFilename, strTemp);
  1188. isRunning = profiler->IsRunning();
  1189. if (isRunning) {
  1190. std::cout << profiler->GetInfos() << std::endl;
  1191. std::cout << "Notice: Profiler Start successfully." << std::endl;
  1192. }
  1193. else {
  1194. std::cout << "Notice: Profiler Start failed." << std::endl;
  1195. }
  1196. }
  1197. else {
  1198. profiler->Stop(strTemp);
  1199. isRunning = profiler->IsRunning();
  1200. if (!isRunning) {
  1201. lse_ns_util::util::Profiler::FreeInstance();
  1202. std::cout << "Notice: Profiler Stop successfully." << std::endl;
  1203. }
  1204. else {
  1205. std::cout << "Notice: Profiler Stop failed." << std::endl;
  1206. }
  1207. }
  1208. }
  1209.  
  1210. void loopop() {
  1211. int n = ;
  1212. while () {
  1213. for (int i = ; i < ; i++) {
  1214. for (int j = ; j < ; j++) {
  1215. n |= i % + j / ;
  1216. }
  1217. }
  1218. std::cout << lse_ns_util::common::TimeToTimestampStr(time(cpp::nullptr)) << " - result: " << n << std::endl;
  1219. }
  1220. return;
  1221. }
  1222.  
  1223. // Compile command : ${CXX} -o test_profiler.elf -DUSE_GPERFTOOLS -DDEBUG -D_DEBUG ${CXXFLAGS} -O0 -g -Wall ${LIBS} -lprofiler ${BUILD_LDFLAGS} test_profiler.cpp
  1224. // Bash Command : kill -s SIGUSR1 <PID>
  1225. // CPU Profiler command : gperftools/bin/pprof -text test_profiler.elf test_profiler.prof
  1226. // see https://github.com/gperftools/gperftools/wiki
  1227.  
  1228. int main(int argc, char *argv[]) {
  1229.  
  1230. if (lse_ns_util::util::setupSignal(SIGUSR1, profilerSignalHandler) != ) {
  1231. return -;
  1232. }
  1233. else {
  1234. loopop();
  1235. return ;
  1236. }
  1237.  
  1238. }
  1239.  
  1240. /* End of test_profiler.cpp */

==================== End

gperftools cpp wrapper的更多相关文章

  1. awesome cpp

    https://github.com/fffaraz/awesome-cpp Awesome C/C++ A curated list of awesome C/C++ frameworks, lib ...

  2. google开源的C++性能分析工具 - gperftools

    gperftools是Google提供的一套工具,其中的一个功能是CPU profiler,用于分析程序性能,找到程序的性能瓶颈. 安装 gperftools:http://code.google.c ...

  3. 试写foxit reader的ConvertToPDF功能的wrapper

    相比于直接fuzzing大型程序本身,针对程序的某一特定功能写wrapper后再fuzzing则要高效的多.网上搜了下,仅有两篇关于foxit reader的wrapper文章,一个用python,另 ...

  4. gperftools对程序进行分析

    gperftools是google出品的一个性能分析工具,相关介绍可见:https://github.com/gperftools/gperftools/wikigperftools性能分析通过抽样方 ...

  5. 混合编译.c/.cpp与.cu文件

    混合编译.c/.cpp与.cu文件 项目中用到cuda编程,写了kernel函数,需要nvcc编译器来编译..c/.cpp的文件,假定用gcc编译. 如何混合编译它们,整体思路是:.cu文件编译出的东 ...

  6. 文本分类学习 (十)构造机器学习Libsvm 的C# wrapper(调用c/c++动态链接库)

    前言: 对于SVM的了解,看前辈写的博客加上读论文对于SVM的皮毛知识总算有点了解,比如线性分类器,和求凸二次规划中用到的高等数学知识.然而SVM最核心的地方应该在于核函数和求关于α函数的极值的方法: ...

  7. gperftools 使用经验总结

    先看了网上的一些资料,但都不太适合我.还是看了详细的资料才学会怎么用. 按照 http://www.cnblogs.com/persistentsnail/p/3294843.html,yum安装gp ...

  8. 性能测试工具gperftools使用

    https://blog.csdn.net/10km/article/details/83820080 https://blog.51cto.com/wulingdong/2043898 https: ...

  9. SQLite wrapper

    SQLiteWrapper is a C++ wrapper for SQLite. There are some test programs that demonstrate how the SQL ...

随机推荐

  1. Nslookup: command not found error on RHEL/CentOS 7

    Reference: https://unix.stackexchange.com/questions/164210/nslookup-command-not-found-error-on-rhel- ...

  2. Rocketmq同步发送消息

    package com.bfxy.rocketmq.quickstart; import org.apache.rocketmq.client.exception.MQBrokerException; ...

  3. Android ListView多布局

    使用listview多布局会出现一点问题: 由于多个item布局给单一的item布局是不一样的,使用起来,contentview的复用会出现问题. 避免出现问题的有这几个方法: 1.重写 getVie ...

  4. 如何解决AndroidStudio下载资源慢的问题

    https://blog.csdn.net/LiangJianxiong/article/details/87881150方法1.build.gradle里的buildscript和allprojec ...

  5. You don't have permission to access / on this server. wampserver3.1.0配置外网访问的问题

    参考各种wamp教程后外网仍然不能访问服务器,很是头疼 网上好多wampserver配置都比较久远,最新版本3.1.0的很少,首先打开httpd.conf文件(这部分较简略,详细可以参考其他wamp配 ...

  6. LC 275. H-Index II

    Given an array of citations sorted in ascending order (each citation is a non-negative integer) of a ...

  7. SQL:目录

    ylbtech-SQL:目录 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   作者:ylbtech出处:http://ylbtech.c ...

  8. spring + mybatis + mysql/oracle开发

    1)创建一个spring-mybatis-mysql这么一个javaweb或java工程 2)导入spring-ioc,spring-aop,spring-transaction,mybatis,c3 ...

  9. Hander创建消息

    每一个消息都需要被指定的Handler处理,通过Handler创建消息便可以完成此功能.Android消息机制中引入了消息池.Handler创建消息时首先查询消息池中是否有消息存在,如果有直接从消息池 ...

  10. python MySQLdb连接mysql时报错

    故障现象: >>> import MySQLdb >>> conn = MySQLdb.connect(host=,charset="utf8" ...