Skip to content

Instantly share code, notes, and snippets.

@sehe
Created February 17, 2016 09:16
Show Gist options
  • Save sehe/5f060a3daccfdff3178c to your computer and use it in GitHub Desktop.
Save sehe/5f060a3daccfdff3178c to your computer and use it in GitHub Desktop.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Command: ./test Command: ./test
Massif arguments: (none) Massif arguments: (none)
ms_print arguments: massif.out.12835 | ms_print arguments: massif.out.17227
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
GB GB
1.604^ # | 1.605^ :
| :@:# | | :###################################################################:
| :::::@:#: | | :# :
| ::::: : :@:#: | | :# :
| ::::::: : :@:#:: | | @# :
| :::::::::: : :@:#::: | | :@# :
| @::::::::::::: : :@:#::: | | @@# :
| ::@: ::::::::::: : :@:#:::: | | @@# :
| :::@::@: ::::::::::: : :@:#:::: | | @@# :
| ::::::@::@: ::::::::::: : :@:#::::: | | @@# :
| ::::: :::@::@: ::::::::::: : :@:#::::: | | :@@# :
| ::: ::: :::@::@: ::::::::::: : :@:#:::::: | | :@@# :
| :::::: ::: :::@::@: ::::::::::: : :@:#::::::@ | | :@@# @
| @:@: :::: ::: :::@::@: ::::::::::: : :@:#::::::@ | | :@@# @
| :::@:@: :::: ::: :::@::@: ::::::::::: : :@:#::::::@: | | :@@# @
| @:::: @:@: :::: ::: :::@::@: ::::::::::: : :@:#::::::@: | |::@@# @
| @:@: :: @:@: :::: ::: :::@::@: ::::::::::: : :@:#::::::@:: | |::@@# @
| :::@:@: :: @:@: :::: ::: :::@::@: ::::::::::: : :@:#::::::@:: | |::@@# @
| @:::::@:@: :: @:@: :::: ::: :::@::@: ::::::::::: : :@:#::::::@::: | |@:@@# @
| :::@: :::@:@: :: @:@: :::: ::: :::@::@: ::::::::::: : :@:#::::::@:::: | |@:@@# @
0 +----------------------------------------------------------------------->Gi 0 +----------------------------------------------------------------------->Gi
0 5.697 | 0 82.82
Number of snapshots: 71 | Number of snapshots: 67
Detailed snapshots: [5, 10, 12, 16, 18, 30, 33, 48, 50, 53 (peak), 63] | Detailed snapshots: [5, 35, 39, 48, 50 (peak), 60]
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
0 0 0 0 0 0 0 0 0 0 0 0
1 103,646,769 39,627,624 35,799,576 3,828,048 0 | 1 94,023,746 35,849,072 32,387,824 3,461,248 0
2 181,769,524 69,946,640 63,183,920 6,762,720 0 | 2 168,319,483 64,832,312 58,537,928 6,294,384 0
3 313,605,544 119,594,000 108,024,192 11,569,808 0 | 3 283,873,383 108,756,912 98,216,320 10,540,592 0
4 393,137,544 146,083,048 132,001,064 14,081,984 0 | 4 375,388,567 140,960,920 127,359,304 13,601,616 0
5 518,089,740 188,780,808 170,938,696 17,842,112 0 | 5 526,914,852 192,587,128 174,421,896 18,165,232 0
90.55% (170,938,696B) (heap allocation functions) malloc/new/new[], --alloc-fns, e | 90.57% (174,421,896B) (heap allocation functions) malloc/new/new[], --alloc-fns, e
->45.87% (86,597,616B) 0x406385: Tree::Node<(unsigned char)10>::set_child(unsigned | ->46.72% (89,975,088B) 0x4073B5: Tree::Node<(unsigned char)10>::set_child(unsigned
| ->42.88% (80,948,616B) 0x403B0A: main (test.cpp:239) | | ->43.21% (83,215,944B) 0x40496A: main (test.cpp:239)
| | | |
| ->02.99% (5,649,000B) 0x403B54: main (test.cpp:257) | | ->03.51% (6,759,144B) 0x4049B5: main (test.cpp:257)
| |
->23.01% (43,429,136B) 0x40725D: Tree::Node<(unsigned char)9>::set_child(unsigned | ->22.36% (43,053,696B) 0x40828D: Tree::Node<(unsigned char)9>::set_child(unsigned
| ->20.04% (37,825,808B) 0x403B0A: main (test.cpp:239) | | ->19.45% (37,450,368B) 0x40496A: main (test.cpp:239)
| | | |
| ->02.97% (5,603,328B) 0x403B54: main (test.cpp:257) | | ->02.91% (5,603,328B) 0x4049B5: main (test.cpp:257)
| |
->10.41% (19,651,320B) 0x40739D: Tree::Node<(unsigned char)8>::set_child(unsigned | ->10.20% (19,651,320B) 0x4083CD: Tree::Node<(unsigned char)8>::set_child(unsigned
| ->09.20% (17,365,568B) 0x403B0A: main (test.cpp:239) | | ->09.02% (17,365,568B) 0x40496A: main (test.cpp:239)
| | | |
| ->01.21% (2,285,752B) 0x403B54: main (test.cpp:257) | | ->01.19% (2,285,752B) 0x4049B5: main (test.cpp:257)
| |
->04.51% (8,519,160B) 0x4074C5: Tree::Node<(unsigned char)7>::set_child(unsigned c | ->04.42% (8,519,160B) 0x4084F5: Tree::Node<(unsigned char)7>::set_child(unsigned c
| ->04.02% (7,586,040B) 0x403B0A: main (test.cpp:239) | | ->03.94% (7,586,040B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.49% (933,120B) in 1+ places, all below ms_print's threshold (01.00%) | | ->00.48% (933,120B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->02.99% (5,649,168B) 0x40A30B: Tree::Node<(unsigned char)9>::upgrade() (test.cpp: | ->03.51% (6,759,312B) 0x40B43B: Tree::Node<(unsigned char)9>::upgrade() (test.cpp:
| ->02.99% (5,649,000B) 0x403B1F: main (test.cpp:252) | | ->03.51% (6,759,144B) 0x404980: main (test.cpp:252)
| | | |
| ->00.00% (168B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.00% (168B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->01.71% (3,227,224B) 0x4075D5: Tree::Node<(unsigned char)6>::set_child(unsigned c | ->01.68% (3,236,096B) in 20 places, all below massif's threshold (01.00%)
| ->01.54% (2,902,224B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.17% (325,000B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->01.32% (2,490,368B) 0x40A37B: Tree::Node<(unsigned char)8>::upgrade() (test.cpp: <
| ->01.32% (2,490,368B) 0x403B1F: main (test.cpp:252) <
| | <
| ->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->00.73% (1,374,704B) in 1+ places, all below ms_print's threshold (01.00%) <
<
-------------------------------------------------------------------------------- <
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) <
-------------------------------------------------------------------------------- <
6 669,625,694 244,948,744 221,864,376 23,084,368 0 <
7 774,252,746 282,352,424 255,623,240 26,729,184 0 <
8 868,046,781 315,348,712 285,437,688 29,911,024 0 <
9 940,997,771 340,786,624 308,465,440 32,321,184 0 <
10 1,042,725,774 377,717,024 342,102,320 35,614,704 0 <
90.57% (342,102,320B) (heap allocation functions) malloc/new/new[], --alloc-fns, e <
->48.61% (183,608,880B) 0x406385: Tree::Node<(unsigned char)10>::set_child(unsigne <
| ->45.66% (172,448,640B) 0x403B0A: main (test.cpp:239) <
| | <
| ->02.95% (11,160,240B) 0x403B54: main (test.cpp:257) <
| <
->21.67% (81,866,288B) 0x40725D: Tree::Node<(unsigned char)9>::set_child(unsigned <
| ->20.36% (76,885,552B) 0x403B0A: main (test.cpp:239) <
| | <
| ->01.32% (4,980,736B) 0x403B54: main (test.cpp:257) <
| <
->10.41% (39,302,640B) 0x40739D: Tree::Node<(unsigned char)8>::set_child(unsigned <
| ->09.80% (37,016,888B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.61% (2,285,752B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->04.51% (17,038,320B) 0x4074C5: Tree::Node<(unsigned char)7>::set_child(unsigned <
| ->04.26% (16,105,200B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.25% (933,120B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->02.95% (11,160,240B) 0x40A30B: Tree::Node<(unsigned char)9>::upgrade() (test.cpp <
| ->02.95% (11,160,072B) 0x403B1F: main (test.cpp:252) <
| | <
| ->00.00% (168B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->01.71% (6,454,448B) 0x4075D5: Tree::Node<(unsigned char)6>::set_child(unsigned c <
| ->01.62% (6,129,448B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.09% (325,000B) in 1+ places, all below ms_print's threshold (01.00%) <
| |
->00.71% (2,671,504B) in 1+ places, all below ms_print's threshold (01.00%) | ->01.68% (3,227,224B) 0x408605: Tree::Node<(unsigned char)6>::set_child(unsigned c
| ->01.51% (2,902,224B) 0x40496A: main (test.cpp:239)
-------------------------------------------------------------------------------- | |
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) | ->00.17% (325,000B) in 1+ places, all below ms_print's threshold (01.00%)
-------------------------------------------------------------------------------- <
11 1,157,362,857 419,230,112 379,553,344 39,676,768 0 <
12 1,251,156,076 452,403,792 409,504,912 42,898,880 0 <
90.52% (409,504,912B) (heap allocation functions) malloc/new/new[], --alloc-fns, e <
->47.36% (214,251,576B) 0x406385: Tree::Node<(unsigned char)10>::set_child(unsigne <
| ->44.89% (203,091,336B) 0x403B0A: main (test.cpp:239) <
| | <
| ->02.47% (11,160,240B) 0x403B54: main (test.cpp:257) <
| <
->22.08% (99,889,384B) 0x40725D: Tree::Node<(unsigned char)9>::set_child(unsigned <
| ->20.98% (94,908,648B) 0x403B0A: main (test.cpp:239) <
| | <
| ->01.10% (4,980,736B) 0x403B54: main (test.cpp:257) <
| <
->10.89% (49,257,704B) 0x40739D: Tree::Node<(unsigned char)8>::set_child(unsigned <
| ->10.38% (46,971,952B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.51% (2,285,752B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->04.89% (22,116,120B) 0x4074C5: Tree::Node<(unsigned char)7>::set_child(unsigned <
| ->04.68% (21,183,000B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.21% (933,120B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->02.47% (11,160,240B) 0x40A30B: Tree::Node<(unsigned char)9>::upgrade() (test.cpp <
| ->02.47% (11,160,072B) 0x403B1F: main (test.cpp:252) <
| | <
| ->00.00% (168B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->01.96% (8,861,632B) 0x4075D5: Tree::Node<(unsigned char)6>::set_child(unsigned c <
| ->01.89% (8,536,632B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.07% (325,000B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->00.88% (3,968,256B) in 1+ places, all below ms_print's threshold (01.00%) <
<
-------------------------------------------------------------------------------- <
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) <
-------------------------------------------------------------------------------- <
13 1,358,924,420 489,830,544 443,323,632 46,506,912 0 <
14 1,507,608,563 542,642,656 491,325,216 51,317,440 0 <
15 1,611,896,323 580,288,440 525,341,240 54,947,200 0 <
16 1,727,539,755 620,882,056 561,970,328 58,911,728 0 <
90.51% (561,970,328B) (heap allocation functions) malloc/new/new[], --alloc-fns, e <
->47.19% (293,009,136B) 0x406385: Tree::Node<(unsigned char)10>::set_child(unsigne <
| ->45.39% (281,848,896B) 0x403B0A: main (test.cpp:239) <
| | <
| ->01.80% (11,160,240B) 0x403B54: main (test.cpp:257) <
| <
->22.69% (140,851,712B) 0x40725D: Tree::Node<(unsigned char)9>::set_child(unsigned <
| ->21.88% (135,870,976B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.80% (4,980,736B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->11.10% (68,929,288B) 0x40739D: Tree::Node<(unsigned char)8>::set_child(unsigned <
| ->10.73% (66,643,536B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.37% (2,285,752B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->04.94% (30,652,680B) 0x4074C5: Tree::Node<(unsigned char)7>::set_child(unsigned <
| ->04.79% (29,719,560B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.15% (933,120B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->01.95% (12,100,192B) 0x4075D5: Tree::Node<(unsigned char)6>::set_child(unsigned <
| ->01.90% (11,775,192B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.05% (325,000B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->01.80% (11,160,240B) 0x40A30B: Tree::Node<(unsigned char)9>::upgrade() (test.cpp <
| ->01.80% (11,160,072B) 0x403B1F: main (test.cpp:252) <
| | <
| ->00.00% (168B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->00.85% (5,267,080B) in 1+ places, all below ms_print's threshold (01.00%) <
<
-------------------------------------------------------------------------------- <
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) <
-------------------------------------------------------------------------------- <
17 1,793,622,115 643,707,848 582,602,504 61,105,344 0 <
18 1,892,745,711 677,858,512 613,504,656 64,353,856 0 <
90.51% (613,504,656B) (heap allocation functions) malloc/new/new[], --alloc-fns, e <
->46.73% (316,729,392B) 0x406385: Tree::Node<(unsigned char)10>::set_child(unsigne <
| ->45.08% (305,569,152B) 0x403B0A: main (test.cpp:239) <
| | <
| ->01.65% (11,160,240B) 0x403B54: main (test.cpp:257) <
| <
->22.83% (154,757,128B) 0x40725D: Tree::Node<(unsigned char)9>::set_child(unsigned <
| ->22.10% (149,776,392B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.73% (4,980,736B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->11.60% (78,605,280B) 0x40739D: Tree::Node<(unsigned char)8>::set_child(unsigned <
| ->11.26% (76,319,528B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.34% (2,285,752B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->05.03% (34,076,640B) 0x4074C5: Tree::Node<(unsigned char)7>::set_child(unsigned <
| ->04.89% (33,143,520B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.14% (933,120B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->01.90% (12,908,896B) 0x4075D5: Tree::Node<(unsigned char)6>::set_child(unsigned <
| ->01.86% (12,583,896B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.05% (325,000B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->01.65% (11,160,240B) 0x40A30B: Tree::Node<(unsigned char)9>::upgrade() (test.cpp <
| ->01.65% (11,160,072B) 0x403B1F: main (test.cpp:252) <
| | <
| ->00.00% (168B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->00.78% (5,267,080B) in 1+ places, all below ms_print's threshold (01.00%) <
<
-------------------------------------------------------------------------------- <
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) <
-------------------------------------------------------------------------------- <
19 2,028,081,062 726,186,016 657,398,240 68,787,776 0 <
20 2,142,445,590 766,699,704 693,994,504 72,705,200 0 <
21 2,225,049,019 795,188,536 719,713,576 75,474,960 0 <
22 2,307,651,855 823,486,160 745,274,224 78,211,936 0 <
23 2,417,789,985 861,427,928 779,675,384 81,752,544 0 <
24 2,551,507,546 908,855,240 822,685,608 86,169,632 0 <
25 2,673,722,578 951,210,408 860,950,536 90,259,872 0 <
26 2,783,860,321 988,689,080 894,799,624 93,889,456 0 <
27 2,921,532,672 1,035,826,704 937,554,864 98,271,840 0 <
28 2,992,416,989 1,060,637,672 960,093,640 100,544,032 0 <
29 3,088,614,658 1,093,608,320 989,883,936 103,724,384 0 <
30 3,159,328,269 1,117,619,984 1,011,605,104 106,014,880 0 <
90.51% (1,011,605,104B) (heap allocation functions) malloc/new/new[], --alloc-fns, <
->47.06% (525,999,600B) 0x406385: Tree::Node<(unsigned char)10>::set_child(unsigne <
| ->46.07% (514,839,360B) 0x403B0A: main (test.cpp:239) <
| | <
| ->01.00% (11,160,240B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->23.40% (261,577,712B) 0x40725D: Tree::Node<(unsigned char)9>::set_child(unsigned <
| ->22.96% (256,596,976B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.45% (4,980,736B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->11.33% (126,590,704B) 0x40739D: Tree::Node<(unsigned char)8>::set_child(unsigned <
| ->11.12% (124,304,952B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.20% (2,285,752B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->04.96% (55,449,840B) 0x4074C5: Tree::Node<(unsigned char)7>::set_child(unsigned <
| ->04.88% (54,516,720B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.08% (933,120B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->02.02% (22,598,160B) 0x4075D5: Tree::Node<(unsigned char)6>::set_child(unsigned <
| ->01.88% (20,973,160B) 0x403B0A: main (test.cpp:239) <
| | <
| ->00.15% (1,625,000B) in 1+ places, all below ms_print's threshold (01.00%) <
| <
->01.73% (19,389,088B) in 21 places, all below massif's threshold (01.00%) <
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
31 3,241,931,182 1,145,132,856 1,036,430,936 108,701,920 0 | 6 609,171,528 223,236,800 202,251,680 20,985,120 0
32 3,324,534,204 1,173,072,352 1,061,713,392 111,358,960 0 | 7 738,515,388 270,104,144 244,559,008 25,545,136 0
33 3,461,082,323 1,220,193,456 1,104,578,480 115,614,976 0 | 8 837,228,173 304,999,904 276,076,704 28,923,200 0
90.52% (1,104,578,480B) (heap allocation functions) malloc/new/new[], --alloc-fns, | 9 921,654,398 334,758,400 303,000,192 31,758,208 0
->47.30% (577,198,440B) 0x406385: Tree::Node<(unsigned char)10>::set_child(unsigne | 10 1,006,080,484 365,047,096 330,534,136 34,512,960 0
| ->46.39% (566,038,200B) 0x403B0A: main (test.cpp:239) | 11 1,103,935,192 400,870,928 362,984,160 37,886,768 0
> 12 1,230,575,751 446,134,976 403,861,600 42,273,376 0
> 13 1,304,449,363 471,880,512 427,095,888 44,784,624 0
> 14 1,407,952,834 507,907,008 459,693,792 48,213,216 0
> 15 1,479,796,460 533,712,584 483,171,672 50,540,912 0
> 16 1,577,085,570 569,009,168 515,144,000 53,865,168 0
> 17 1,702,811,604 613,582,784 555,403,232 58,179,552 0
> 18 1,774,655,350 638,453,424 577,841,792 60,611,632 0
> 19 1,882,420,851 675,631,376 611,476,368 64,155,008 0
> 20 1,954,264,652 701,161,816 634,699,416 66,462,400 0
> 21 2,054,708,770 737,294,824 667,437,896 69,856,928 0
> 22 2,154,910,109 772,531,824 699,243,440 73,288,384 0
> 23 2,219,190,087 794,734,616 719,299,240 75,435,376 0
> 24 2,332,622,391 833,753,792 754,577,920 79,175,872 0
> 25 2,417,696,714 863,079,232 781,177,712 81,901,520 0
> 26 2,547,121,574 909,166,896 822,966,240 86,200,656 0
> 27 2,641,601,719 941,961,488 852,582,528 89,378,960 0
> 28 2,783,392,242 990,448,544 896,386,240 94,062,304 0
> 29 2,868,467,039 1,019,507,784 922,715,144 96,792,640 0
> 30 2,953,542,030 1,049,309,856 949,865,568 99,444,288 0
> 31 3,034,873,680 1,077,430,512 975,267,712 102,162,800 0
> 32 3,131,896,292 1,110,390,984 1,005,047,832 105,343,152 0
> 33 3,209,534,679 1,136,583,512 1,028,729,528 107,853,984 0
> 34 3,322,967,349 1,174,848,048 1,063,318,480 111,529,568 0
> 35 3,436,400,357 1,214,014,048 1,098,936,416 115,077,632 0
> 90.52% (1,098,936,416B) (heap allocation functions) malloc/new/new[], --alloc-fns,
> ->47.08% (571,556,496B) 0x4073B5: Tree::Node<(unsigned char)10>::set_child(unsigne
> | ->46.16% (560,396,256B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.91% (11,160,240B) in 1+ places, all below ms_print's threshold (01.00%) | | ->00.92% (11,160,240B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->23.48% (286,532,008B) 0x40725D: Tree::Node<(unsigned char)9>::set_child(unsigned | ->23.60% (286,532,008B) 0x40828D: Tree::Node<(unsigned char)9>::set_child(unsigned
| ->23.07% (281,551,272B) 0x403B0A: main (test.cpp:239) | | ->23.19% (281,551,272B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.41% (4,980,736B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.41% (4,980,736B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->11.27% (137,559,240B) 0x40739D: Tree::Node<(unsigned char)8>::set_child(unsigned | ->11.33% (137,559,240B) 0x4083CD: Tree::Node<(unsigned char)8>::set_child(unsigned
| ->11.09% (135,273,488B) 0x403B0A: main (test.cpp:239) | | ->11.14% (135,273,488B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.19% (2,285,752B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.19% (2,285,752B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->04.89% (59,634,120B) 0x4074C5: Tree::Node<(unsigned char)7>::set_child(unsigned | ->04.91% (59,634,120B) 0x4084F5: Tree::Node<(unsigned char)7>::set_child(unsigned
| ->04.81% (58,701,000B) 0x403B0A: main (test.cpp:239) | | ->04.84% (58,701,000B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.08% (933,120B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.08% (933,120B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->01.98% (24,215,568B) 0x4075D5: Tree::Node<(unsigned char)6>::set_child(unsigned | ->01.99% (24,215,568B) 0x408605: Tree::Node<(unsigned char)6>::set_child(unsigned
| ->01.82% (22,265,568B) 0x403B0A: main (test.cpp:239) | | ->01.83% (22,265,568B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.16% (1,950,000B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.16% (1,950,000B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->01.59% (19,439,104B) in 21 places, all below massif's threshold (01.00%) | ->01.60% (19,438,984B) in 21 places, all below massif's threshold (01.00%)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
34 3,553,224,630 1,250,447,656 1,131,930,664 118,516,992 0 | 36 3,591,137,192 1,265,134,200 1,145,215,224 119,918,976 0
35 3,655,729,501 1,283,709,368 1,162,020,008 121,689,360 0 | 37 3,694,504,326 1,298,457,624 1,175,361,816 123,095,808 0
36 3,760,358,786 1,316,995,824 1,192,132,256 124,863,568 0 | 38 3,818,829,414 1,339,219,704 1,212,247,624 126,972,080 0
37 3,843,731,889 1,344,998,432 1,217,471,296 127,527,136 0 | 39 3,967,938,143 1,390,359,344 1,258,745,248 131,614,096 0
38 3,927,105,410 1,373,131,640 1,243,015,608 130,116,032 0 | 90.53% (1,258,745,248B) (heap allocation functions) malloc/new/new[], --alloc-fns,
39 4,017,734,936 1,402,554,880 1,269,798,832 132,756,048 0 | ->47.18% (655,916,352B) 0x4073B5: Tree::Node<(unsigned char)10>::set_child(unsigne
40 4,130,014,236 1,436,665,784 1,300,732,408 135,933,376 0 | | ->46.37% (644,756,112B) 0x40496A: main (test.cpp:239)
41 4,244,562,156 1,470,787,800 1,331,676,792 139,111,008 0 <
42 4,302,687,202 1,487,857,624 1,347,159,048 140,698,576 0 <
43 4,403,066,201 1,518,857,416 1,375,259,784 143,597,632 0 <
44 4,486,439,328 1,546,853,488 1,400,685,312 146,168,176 0 <
45 4,575,843,614 1,574,254,520 1,425,683,784 148,570,736 0 <
46 4,709,282,366 1,609,952,728 1,458,194,728 151,758,000 0 <
47 4,845,245,986 1,645,754,440 1,490,799,624 154,954,816 0 <
48 4,942,046,598 1,671,450,432 1,514,207,312 157,243,120 0 <
90.59% (1,514,207,312B) (heap allocation functions) malloc/new/new[], --alloc-fns, <
->46.42% (775,912,872B) 0x406385: Tree::Node<(unsigned char)10>::set_child(unsigne <
| ->45.75% (764,752,632B) 0x403B0A: main (test.cpp:239) <
| | | |
| ->00.67% (11,160,240B) in 1+ places, all below ms_print's threshold (01.00%) | | ->00.80% (11,160,240B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->25.26% (422,250,984B) 0x40725D: Tree::Node<(unsigned char)9>::set_child(unsigned | ->23.55% (327,465,152B) 0x40828D: Tree::Node<(unsigned char)9>::set_child(unsigned
| ->23.18% (387,385,832B) 0x403B0A: main (test.cpp:239) | | ->23.19% (322,484,416B) 0x40496A: main (test.cpp:239)
| | <
| ->02.09% (34,865,152B) 0x403B54: main (test.cpp:257) <
| <
->10.76% (179,837,968B) 0x40739D: Tree::Node<(unsigned char)8>::set_child(unsigned <
| ->09.67% (161,551,952B) 0x403B0A: main (test.cpp:239) <
| | <
| ->01.09% (18,286,016B) 0x403B54: main (test.cpp:257) <
| <
->03.90% (65,232,840B) 0x4074C5: Tree::Node<(unsigned char)7>::set_child(unsigned <
| ->03.57% (59,634,120B) 0x403B0A: main (test.cpp:239) <
| | | |
| ->00.33% (5,598,720B) in 1+ places, all below ms_print's threshold (01.00%) | | ->00.36% (4,980,736B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->01.79% (29,884,568B) 0x40A37B: Tree::Node<(unsigned char)8>::upgrade() (test.cpp | ->11.31% (157,210,560B) 0x4083CD: Tree::Node<(unsigned char)8>::set_child(unsigned
| ->01.79% (29,884,568B) 0x403B1F: main (test.cpp:252) | | ->11.14% (154,924,808B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%) | | ->00.16% (2,285,752B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->01.26% (20,988,344B) 0x4075D5: Tree::Node<(unsigned char)6>::set_child(unsigned | ->05.30% (73,752,000B) 0x4084F5: Tree::Node<(unsigned char)7>::set_child(unsigned
| ->01.16% (19,363,344B) 0x403B0A: main (test.cpp:239) | | ->04.83% (67,220,160B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.10% (1,625,000B) in 1+ places, all below ms_print's threshold (01.00%) | | ->00.47% (6,531,840B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->01.20% (20,099,736B) in 20 places, all below massif's threshold (01.00%) | ->01.68% (23,412,840B) in 21 places, all below massif's threshold (01.00%)
> |
> ->01.51% (20,988,344B) 0x408605: Tree::Node<(unsigned char)6>::set_child(unsigned
> ->01.39% (19,363,344B) 0x40496A: main (test.cpp:239)
> |
> ->00.12% (1,625,000B) in 1+ places, all below ms_print's threshold (01.00%)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
49 4,983,733,037 1,681,545,000 1,523,405,112 158,139,888 0 | 40 4,059,616,549 1,417,975,992 1,283,785,000 134,190,992 0
50 5,012,236,942 1,689,429,952 1,530,586,816 158,843,136 0 | 41 4,172,830,425 1,452,182,680 1,314,804,504 137,378,176 0
> 42 4,288,313,282 1,486,340,816 1,345,784,080 140,556,736 0
> 43 4,418,749,800 1,526,898,264 1,382,547,480 144,350,784 0
> 44 4,560,969,656 1,572,817,656 1,424,374,888 148,442,768 0
> 45 4,694,208,483 1,608,624,824 1,456,984,584 151,640,240 0
> 46 4,829,971,448 1,644,425,056 1,489,587,952 154,837,104 0
> 47 4,898,800,062 1,662,288,640 1,505,861,616 156,427,024 0
> 48 5,002,426,965 1,689,429,952 1,530,586,816 158,843,136 0
90.60% (1,530,586,816B) (heap allocation functions) malloc/new/new[], --alloc-fns, 90.60% (1,530,586,816B) (heap allocation functions) malloc/new/new[], --alloc-fns,
->46.33% (782,792,640B) 0x406385: Tree::Node<(unsigned char)10>::set_child(unsigne | ->46.33% (782,792,640B) 0x4073B5: Tree::Node<(unsigned char)10>::set_child(unsigne
| ->45.67% (771,632,400B) 0x403B0A: main (test.cpp:239) | | ->45.67% (771,632,400B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.66% (11,160,240B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.66% (11,160,240B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->25.52% (431,226,432B) 0x40725D: Tree::Node<(unsigned char)9>::set_child(unsigned | ->25.52% (431,226,432B) 0x40828D: Tree::Node<(unsigned char)9>::set_child(unsigned
| ->23.17% (391,380,544B) 0x403B0A: main (test.cpp:239) | | ->23.17% (391,380,544B) 0x40496A: main (test.cpp:239)
| | | |
| ->02.36% (39,845,888B) 0x403B54: main (test.cpp:257) | | ->02.36% (39,845,888B) 0x4049B5: main (test.cpp:257)
| |
->10.52% (177,667,272B) 0x40739D: Tree::Node<(unsigned char)8>::set_child(unsigned | ->10.52% (177,667,272B) 0x4083CD: Tree::Node<(unsigned char)8>::set_child(unsigned
| ->09.43% (159,381,256B) 0x403B0A: main (test.cpp:239) | | ->09.43% (159,381,256B) 0x40496A: main (test.cpp:239)
| | | |
| ->01.08% (18,286,016B) 0x403B54: main (test.cpp:257) | | ->01.08% (18,286,016B) 0x4049B5: main (test.cpp:257)
| |
->03.86% (65,232,840B) 0x4074C5: Tree::Node<(unsigned char)7>::set_child(unsigned | ->03.86% (65,232,840B) 0x4084F5: Tree::Node<(unsigned char)7>::set_child(unsigned
| ->03.53% (59,634,120B) 0x403B0A: main (test.cpp:239) | | ->03.53% (59,634,120B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.33% (5,598,720B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.33% (5,598,720B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->02.06% (34,865,304B) 0x40A37B: Tree::Node<(unsigned char)8>::upgrade() (test.cpp | ->02.06% (34,865,304B) 0x40B4AB: Tree::Node<(unsigned char)8>::upgrade() (test.cpp
| ->02.06% (34,865,304B) 0x403B1F: main (test.cpp:252) | | ->02.06% (34,865,304B) 0x404980: main (test.cpp:252)
| | | |
| ->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->01.24% (20,988,344B) 0x4075D5: Tree::Node<(unsigned char)6>::set_child(unsigned | ->01.24% (20,988,344B) 0x408605: Tree::Node<(unsigned char)6>::set_child(unsigned
| ->01.15% (19,363,344B) 0x403B0A: main (test.cpp:239) | | ->01.15% (19,363,344B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.10% (1,625,000B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.10% (1,625,000B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->01.05% (17,813,984B) in 20 places, all below massif's threshold (01.00%) ->01.05% (17,813,984B) in 20 places, all below massif's threshold (01.00%)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
51 5,070,362,097 1,703,294,472 1,543,221,608 160,072,864 0 | 49 5,074,272,079 1,707,814,264 1,547,335,480 160,478,784 0
52 5,128,487,199 1,722,634,888 1,560,788,728 161,846,160 0 | 50 5,119,112,256 1,722,827,432 1,560,964,146 161,863,286 0
53 5,129,078,257 1,722,817,904 1,560,954,736 161,863,168 0 | 90.60% (1,560,964,146B) (heap allocation functions) malloc/new/new[], --alloc-fns,
90.60% (1,560,954,736B) (heap allocation functions) malloc/new/new[], --alloc-fns, | ->46.13% (794,685,528B) 0x4073B5: Tree::Node<(unsigned char)10>::set_child(unsigne
->46.13% (794,685,528B) 0x406385: Tree::Node<(unsigned char)10>::set_child(unsigne | | ->45.48% (783,525,288B) 0x40496A: main (test.cpp:239)
| ->45.48% (783,525,288B) 0x403B0A: main (test.cpp:239) <
| | | |
| ->00.65% (11,160,240B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.65% (11,160,240B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->26.07% (449,177,328B) 0x40725D: Tree::Node<(unsigned char)9>::set_child(unsigned | ->26.07% (449,177,328B) 0x40828D: Tree::Node<(unsigned char)9>::set_child(unsigned
| ->23.47% (404,350,704B) 0x403B0A: main (test.cpp:239) | | ->23.47% (404,350,704B) 0x40496A: main (test.cpp:239)
| | | |
| ->02.60% (44,826,624B) 0x403B54: main (test.cpp:257) | | ->02.60% (44,826,624B) 0x4049B5: main (test.cpp:257)
| |
->10.05% (173,210,824B) 0x40739D: Tree::Node<(unsigned char)8>::set_child(unsigned | ->10.05% (173,210,824B) 0x4083CD: Tree::Node<(unsigned char)8>::set_child(unsigned
| ->09.13% (157,210,560B) 0x403B0A: main (test.cpp:239) | | ->09.13% (157,210,560B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.93% (16,000,264B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.93% (16,000,264B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->03.79% (65,232,840B) 0x4074C5: Tree::Node<(unsigned char)7>::set_child(unsigned | ->03.79% (65,232,840B) 0x4084F5: Tree::Node<(unsigned char)7>::set_child(unsigned
| ->03.46% (59,634,120B) 0x403B0A: main (test.cpp:239) | | ->03.46% (59,634,120B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.32% (5,598,720B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.32% (5,598,720B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->02.31% (39,845,888B) 0x40A37B: Tree::Node<(unsigned char)8>::upgrade() (test.cpp | ->02.31% (39,845,888B) 0x40B4AB: Tree::Node<(unsigned char)8>::upgrade() (test.cpp
| ->02.31% (39,845,888B) 0x403B1F: main (test.cpp:252) | | ->02.31% (39,845,888B) 0x404980: main (test.cpp:252)
| | | |
| ->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->01.22% (20,988,344B) 0x4075D5: Tree::Node<(unsigned char)6>::set_child(unsigned | ->01.22% (20,988,344B) 0x408605: Tree::Node<(unsigned char)6>::set_child(unsigned
| ->01.12% (19,363,344B) 0x403B0A: main (test.cpp:239) | | ->01.12% (19,363,344B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.09% (1,625,000B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.09% (1,625,000B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->01.03% (17,813,984B) in 20 places, all below massif's threshold (01.00%) | ->01.03% (17,823,394B) in 29 places, all below massif's threshold (01.00%)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
54 5,187,203,337 1,624,032,832 1,471,817,168 152,215,664 0 | 51 87,959,910,336 1,722,828,264 1,560,964,888 161,863,376 0
55 5,245,328,453 1,524,017,448 1,381,233,320 142,784,128 0 | 52 88,024,190,340 1,613,635,408 1,462,439,120 151,196,288 0
56 5,303,453,548 1,424,978,400 1,291,795,056 133,183,344 0 | 53 88,088,470,343 1,503,049,008 1,362,287,760 140,761,248 0
57 5,361,578,628 1,325,110,192 1,201,385,632 123,724,560 0 | 54 88,152,750,371 1,392,793,464 1,262,521,752 130,271,712 0
58 5,419,703,773 1,225,296,352 1,111,036,144 114,260,208 0 | 55 88,217,030,428 1,283,188,624 1,163,522,816 119,665,808 0
59 5,477,828,823 1,126,130,744 1,021,451,832 104,678,912 0 | 56 88,281,310,477 1,172,715,392 1,063,503,136 109,212,256 0
60 5,535,953,947 1,025,988,280 930,717,592 95,270,688 0 | 57 88,345,590,477 1,062,720,528 964,042,784 98,677,744 0
61 5,594,079,097 927,045,280 841,392,016 85,653,264 0 | 58 88,409,870,456 952,837,624 864,717,464 88,120,160 0
62 5,652,204,163 827,013,416 750,786,968 76,226,448 0 | 59 88,474,150,450 842,126,992 764,416,400 77,710,592 0
63 5,710,329,261 727,632,344 660,943,064 66,689,280 0 | 60 88,538,430,494 732,404,360 665,272,632 67,131,728 0
90.83% (660,943,064B) (heap allocation functions) malloc/new/new[], --alloc-fns, e | 90.83% (665,272,632B) (heap allocation functions) malloc/new/new[], --alloc-fns, e
->54.59% (397,241,376B) 0x406385: Tree::Node<(unsigned char)10>::set_child(unsigne | ->54.41% (398,527,752B) 0x4073B5: Tree::Node<(unsigned char)10>::set_child(unsigne
| ->54.08% (393,508,248B) 0x403B0A: main (test.cpp:239) | | ->53.90% (394,753,128B) 0x40496A: main (test.cpp:239)
| | | | |
| ->00.51% (3,733,128B) in 1+ places, all below ms_print's threshold (01.00%) | | ->00.52% (3,774,624B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->24.81% (180,508,360B) 0x40725D: Tree::Node<(unsigned char)9>::set_child(unsigned | ->25.06% (183,510,056B) 0x40828D: Tree::Node<(unsigned char)9>::set_child(unsigned
| ->23.27% (169,301,704B) 0x403B0A: main (test.cpp:239) | | ->23.53% (172,303,400B) 0x40496A: main (test.cpp:239)
| | | |
| ->01.54% (11,206,656B) 0x403B54: main (test.cpp:257) | | ->01.53% (11,206,656B) 0x4049B5: main (test.cpp:257)
| |
->07.60% (55,302,904B) 0x40739D: Tree::Node<(unsigned char)8>::set_child(unsigned | ->07.55% (55,302,904B) 0x4083CD: Tree::Node<(unsigned char)8>::set_child(unsigned
| ->07.29% (53,017,152B) 0x403B0A: main (test.cpp:239) | | ->07.24% (53,017,152B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.31% (2,285,752B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.31% (2,285,752B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->01.94% (14,117,880B) 0x4074C5: Tree::Node<(unsigned char)7>::set_child(unsigned | ->01.93% (14,117,880B) 0x4084F5: Tree::Node<(unsigned char)7>::set_child(unsigned
| ->01.94% (14,117,880B) 0x403B0A: main (test.cpp:239) | | ->01.93% (14,117,880B) 0x40496A: main (test.cpp:239)
| | | |
| ->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->01.37% (9,961,472B) 0x40A37B: Tree::Node<(unsigned char)8>::upgrade() (test.cpp: | ->01.36% (9,961,472B) 0x40B4AB: Tree::Node<(unsigned char)8>::upgrade() (test.cpp:
| ->01.37% (9,961,472B) 0x403B1F: main (test.cpp:252) | | ->01.36% (9,961,472B) 0x404980: main (test.cpp:252)
| | | |
| ->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
| |
->00.52% (3,811,072B) in 1+ places, all below ms_print's threshold (01.00%) | ->00.53% (3,852,568B) in 1+ places, all below ms_print's threshold (01.00%)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
64 5,768,454,339 627,800,176 570,581,456 57,218,720 0 | 61 88,602,710,518 621,906,224 565,230,400 56,675,824 0
65 5,826,579,385 527,484,832 479,649,296 47,835,536 0 | 62 88,666,990,578 511,080,600 464,805,672 46,274,928 0
66 5,884,704,491 427,699,880 389,367,656 38,332,224 0 | 63 88,731,270,564 400,774,360 365,008,264 35,766,096 0
67 5,942,829,635 326,805,640 297,753,240 29,052,400 0 | 64 88,795,550,562 288,891,384 263,336,616 25,554,768 0
68 6,000,954,705 226,021,312 206,271,760 19,749,552 0 | 65 88,859,830,564 176,844,728 161,472,856 15,371,872 0
69 6,059,079,761 123,577,096 112,837,192 10,739,904 0 | 66 88,924,110,598 63,118,344 57,635,752 5,482,592 0
70 6,117,204,851 20,740,552 18,943,000 1,797,552 0 <
#ifndef TREE_HH
#define TREE_HH
#include <utility>
#include <boost/serialization/export.hpp>
#include <boost/serialization/tracking.hpp>
#include <boost/serialization/split_member.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/preprocessor/tuple/enum.hpp>
#include <unordered_map>
#include <iostream>
using namespace std;
#define FOO_CLASS_TRACKING(E, PARAMETER_TUPLE, ...) \
namespace boost { \
namespace serialization { \
template<BOOST_PP_TUPLE_ENUM(PARAMETER_TUPLE)> \
struct tracking_level< __VA_ARGS__ > \
{ \
typedef mpl::integral_c_tag tag; \
typedef mpl::int_< E> type; \
BOOST_STATIC_CONSTANT( \
int, \
value = tracking_level::type::value \
); \
/* tracking for a class */ \
BOOST_STATIC_ASSERT(( \
mpl::greater< \
/* that is a prmitive */ \
implementation_level< __VA_ARGS__ >, \
mpl::int_<primitive_type> \
>::value \
)); \
}; \
}}
namespace Tree
{
class NodeInterface
{
public:
NodeInterface()
{}
virtual NodeInterface *get_child(const uint8_t i) const = 0;
virtual NodeInterface *set_child(const uint8_t i) = 0;
virtual void set_child(const uint8_t i, NodeInterface *child) = 0;
virtual NodeInterface *upgrade() = 0;
virtual void print(int indention = 0) const = 0;
template <typename Archive>
void save(Archive &ar, const unsigned int version) const
{
}
template <typename Archive>
void load(Archive &ar, const unsigned int version)
{
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
friend class boost::serialization::access;
virtual ~NodeInterface()
{}
};
template <uint8_t num_elem = 1>
class Node;
template<uint8_t num_elem>
NodeInterface *upgrade_node(const Node<num_elem> &node)
{
return new Node<num_elem + 1>;
}
template<>
NodeInterface *upgrade_node(const Node<10> &node)
{
return nullptr;
}
template<uint8_t num_elem>
class Node : public NodeInterface
{
public:
Node():
NodeInterface()
{
for (int i = 0; i < num_elem; ++i)
children[i] = make_pair(0, nullptr);
}
pair<uint8_t, NodeInterface*> children[num_elem];
NodeInterface *get_child(const uint8_t in) const override
{
assert(in < 10);
for (int i = 0; i < num_elem; ++i)
{
if (children[i].second && children[i].first == in)
{
return children[i].second;
}
}
return nullptr;
}
NodeInterface *set_child(const uint8_t in) override
{
assert(in < 10);
for (int i = 0; i < num_elem; ++i)
{
if (children[i].second == nullptr)
{
auto new_node = new Node;
children[i] = make_pair(in, new_node);
return new_node;
}
}
return nullptr;
}
void set_child(const uint8_t in, NodeInterface *child) override
{
assert(in < 10);
for (int i = 0; i < num_elem; ++i)
{
if (children[i].first == in)
{
delete children[i].second;
children[i].second = child;
return;
}
else if (children[i].second == nullptr)
{
children[i] = make_pair(in, child);
return;
}
}
}
void print(int indention = 0) const override
{
string indent_str(indention, ' ');
for (auto & child : children)
{
if (child.second)
{
cout << indent_str << ": " << to_string(child.first) << endl;
child.second->print(indention + 2);
}
}
}
NodeInterface *upgrade() override
{
auto new_node = upgrade_node(*this);
if (new_node)
{
for (int i = 0; i < num_elem; ++i)
{
new_node->set_child(children[i].first, children[i].second);
children[i].second = nullptr;
}
}
return new_node;
}
template <typename Archive>
void save(Archive &ar, const unsigned int version) const
{
ar & boost::serialization::base_object<NodeInterface>(*this);
ar & children;
}
template <typename Archive>
void load(Archive &ar, const unsigned int version)
{
ar & boost::serialization::base_object<NodeInterface>(*this);
ar & children;
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
friend class boost::serialization::access;
~Node()
{
for (int i = 0; i < num_elem; ++i)
{
if (children[i].second)
delete children[i].second;
}
}
};
class Tree
{
public:
NodeInterface *root;
Tree():
root(new Node<>)
{}
void insert(size_t i)
{
auto last_s = root;
auto s = root;
uint32_t last_i = i;
auto temp = root;
while ((temp = s->get_child(i%10)))
{
last_s = s;
last_i = i;
s = temp;
i /= 10;
}
while (i > 0)
{
auto temp = s->set_child(i % 10);
if (temp == nullptr)
{
if (s == root)
{
s = s->upgrade();
delete root;
root = s;
last_s = root;
}
else
{
s = s->upgrade();
last_s->set_child(last_i % 10, s);
}
last_s = s;
s = s->set_child(i % 10);
}
else
{
last_s = s;
s = temp;
}
last_i = i;
i /= 10;
}
}
void print() const
{
root->print();
}
template <typename Archive>
void save(Archive &ar, const unsigned int version) const
{
ar & root;
}
template <typename Archive>
void load(Archive &ar, const unsigned int version)
{
ar & root;
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
friend class boost::serialization::access;
~Tree()
{
delete root;
}
};
} // Tree namepspace
BOOST_CLASS_EXPORT(Tree::Node<1>)
BOOST_CLASS_EXPORT(Tree::Node<2>)
BOOST_CLASS_EXPORT(Tree::Node<3>)
BOOST_CLASS_EXPORT(Tree::Node<4>)
BOOST_CLASS_EXPORT(Tree::Node<5>)
BOOST_CLASS_EXPORT(Tree::Node<6>)
BOOST_CLASS_EXPORT(Tree::Node<7>)
BOOST_CLASS_EXPORT(Tree::Node<8>)
BOOST_CLASS_EXPORT(Tree::Node<9>)
BOOST_CLASS_EXPORT(Tree::Node<10>)
BOOST_CLASS_TRACKING(Tree::NodeInterface, boost::serialization::track_never)
FOO_CLASS_TRACKING(boost::serialization::track_never, (uint8_t num_elem), Tree::Node<num_elem>)
FOO_CLASS_TRACKING(boost::serialization::track_never, (), pair<const uint8_t, Tree::NodeInterface*>)
#endif /* TREE_HH */
//================= main.cc =======================
//#include "tree.hh"
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <fstream>
#define MAX_NUM 10000000
int main()
{
Tree::Tree tree;
for (int i = 0; i < MAX_NUM; ++i)
tree.insert(i);
const char* text_file_name = "/tmp/tree.txt";
{
std::ofstream ofs(text_file_name, ios::binary | ios::out);
std::filebuf *fb = ofs.rdbuf();
boost::archive::binary_oarchive ar(*fb, boost::archive::no_tracking);
cout << "Start serialization..." << endl;
ar & tree;
cout << "Serialization done." << endl;
}
#if 0
{
std::ifstream ifs(text_file_name);
boost::archive::binary_iarchive ar(ifs);
Tree::Tree tree1;
ar & tree1;
tree1.print();
}
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment