Changeset 2503 for trunk/src/win32k/misc/heaptest.c
- Timestamp:
- Jan 23, 2000, 4:20:53 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/misc/heaptest.c
r2501 r2503 1 /* $Id: heaptest.c,v 1. 1 2000-01-22 18:21:03bird Exp $1 /* $Id: heaptest.c,v 1.2 2000-01-23 03:20:52 bird Exp $ 2 2 * 3 3 * Test of resident and swappable heaps. … … 13 13 * Defined Constants 14 14 *******************************************************************************/ 15 #define NUMBER_OF_POINTERS 10240 16 #define RANDOMTEST_ITERATIONS 10240 15 #define NUMBER_OF_POINTERS 16384 16 #define RANDOMTEST_ITERATIONS 65536*2 17 #define Int3() __interrupt(3) 17 18 18 19 … … 22 23 #include "malloc.h" 23 24 #include "rmalloc.h" 25 #include "macros.h" 24 26 #include <stdio.h> 25 27 #include <stdlib.h> 28 #include <memory.h> 29 #include <builtin.h> 26 30 27 31 … … 36 40 unsigned crmalloc; 37 41 unsigned crfree; 38 42 unsigned crealloc; 39 43 int i; 40 44 … … 54 58 * 55 59 */ 60 #if 1 56 61 /* 57 62 * Simple allocation test. … … 62 67 { 63 68 acb[i] = rand(); 64 } while(acb[i] == 0 || acb[i] > 64); 65 69 } while(acb[i] == 0 || acb[i] > 127); 70 71 if ((i % (NUMBER_OF_POINTERS/3)) == 1) 72 acb[i] += 1024*260; 66 73 apv[i] = rmalloc(acb[i]); 67 74 if (apv[i] == NULL) … … 71 78 break; 72 79 } 80 memset(apv[i], 0xA, MIN(acb[i],16)); 73 81 cb += acb[i]; 74 82 } … … 83 91 { 84 92 int cb = _res_msize(apv[i]); 85 if (cb != ((acb[i] + 3) & ~3) && (cb < ((acb[i] + 3) & ~3) || cb > 40+ ((acb[i] + 3) & ~3)) )93 if (cb != ((acb[i] + 3) & ~3) && (cb < ((acb[i] + 3) & ~3) || cb > 52 + ((acb[i] + 3) & ~3)) ) 86 94 printf("size of avp[%d] (%d) != acb[%] (%d)\n", i, cb, i, acb[i]); 87 95 rfree(apv[i]); … … 101 109 printf("\n_res_dump_subheaps:\n"); 102 110 _res_dump_subheaps(); 111 #endif 103 112 104 113 … … 115 124 crfree = 0; 116 125 crmalloc = 0; 126 crealloc = 0; 117 127 while (i++ < RANDOMTEST_ITERATIONS || cAllocations > 0) 118 128 { … … 120 130 j = rand(); 121 131 if (cAllocations + (NUMBER_OF_POINTERS/20) < NUMBER_OF_POINTERS && 122 (i < RANDOMTEST_ITERATIONS*1/4 ? (j % 8) > 1:123 i < RANDOMTEST_ITERATIONS*2/4 ? (j % 8) > 2:124 i < RANDOMTEST_ITERATIONS*3/4 ? (j % 8) > 3:132 (i < RANDOMTEST_ITERATIONS*1/4 ? (j % 8) > 2 : 133 i < RANDOMTEST_ITERATIONS*2/4 ? (j % 8) > 3 : 134 i < RANDOMTEST_ITERATIONS*3/4 ? (j % 8) > 4 : 125 135 i < RANDOMTEST_ITERATIONS ? (j % 8) > 5 : 0 126 136 ) … … 134 144 { 135 145 acb[j] = rand(); 136 } while (acb[j] == 0 || acb[j] > 2048); 146 } while (acb[j] == 0 || (acb[j] > 2048 && (i % 11) != 10)); 147 if ((i % (RANDOMTEST_ITERATIONS/20)) == 1) 148 acb[j] += 1024*256; 137 149 apv[j] = rmalloc(acb[j]); 138 150 if (apv[j] == NULL) … … 141 153 if (acb[j] > 10000) 142 154 continue; 143 } 155 break; 156 } 157 memset(apv[j], 0xA, MIN(acb[j],16)); 144 158 cAllocations++; 145 159 cb += acb[j]; … … 148 162 } 149 163 else 150 { /* free */164 { /* free or realloc */ 151 165 if (cAllocations == 0) 152 166 continue; 167 153 168 if (cAllocations < NUMBER_OF_POINTERS/10) 154 169 { … … 162 177 { 163 178 j = rand(); 164 } while (k < NUMBER_OF_POINTERS/2 && (j >= NUMBER_OF_POINTERS || apv[j] == NULL));179 } while (k++ < NUMBER_OF_POINTERS/2 && (j >= NUMBER_OF_POINTERS || apv[j] == NULL)); 165 180 if (k >= NUMBER_OF_POINTERS/2) 166 181 { … … 173 188 { 174 189 int cb = _res_msize(apv[j]); 175 if (cb != ((acb[j] + 3) & ~3) && (cb < ((acb[j] + 3) & ~3) || cb > 40+ ((acb[j] + 3) & ~3)) )190 if (cb != ((acb[j] + 3) & ~3) && (cb < ((acb[j] + 3) & ~3) || cb > 52 + ((acb[j] + 3) & ~3)) ) 176 191 printf("size of avp[%d] (%d) != acb[%d] (%d)\n", j, cb, j, acb[j]); 177 rfree(apv[j]); 178 apv[j] = NULL; 179 cAllocations--; 180 crfree++; 192 if (i < RANDOMTEST_ITERATIONS*3/4 && j % 3 == 0) 193 { /* realloc */ 194 int cb; 195 void *pv; 196 crealloc++; 197 do 198 { 199 cb = rand(); 200 } while (cb == 0 || cb > 3072); 201 /* 202 if (i >= 0x1c14) 203 Int3(); 204 */ 205 pv = rrealloc(apv[j], cb); 206 if (pv == NULL) 207 { 208 printf("realloc(apv[%d](0x%08), %d) failed\n", j, apv[j], cb); 209 continue; 210 } 211 apv[j] = pv; 212 acb[j] = cb; 213 } 214 else 215 { /* free */ 216 rfree(apv[j]); 217 apv[j] = NULL; 218 cAllocations--; 219 crfree++; 220 } 181 221 } 182 222 } 183 _res_heap_check();184 if (RANDOMTEST_ITERATIONS == i*2)223 /*_res_heap_check();*/ 224 if (RANDOMTEST_ITERATIONS/2 == i) 185 225 _res_dump_subheaps(); 186 } 187 188 printf("cb=%d crfree=%d crmalloc=%d\n", cb, crfree, crmalloc); 226 if ((i % 2048) == 0) 227 printf("i=%d cAllocations=%d\n", i, cAllocations); 228 } 229 230 printf("cb=%d crfree=%d crmalloc=%d crealloc=%d\n", cb, crfree, crmalloc, crealloc); 189 231 190 232 printf("_res_dump_subheaps:\n");
Note:
See TracChangeset
for help on using the changeset viewer.