int main(int argc, char **argv) { RTTEST hTest; RTEXITCODE rcExit = RTTestInitAndCreate("tstDisasm", &hTest); if (rcExit) return rcExit; RTTestBanner(hTest); static const struct { const char *pszDesc; uint8_t const *pbStart; uintptr_t uEndPtr; DISCPUMODE enmCpuMode; } aSnippets[] = { { "32-bit", (uint8_t const *)(uintptr_t)TestProc32, (uintptr_t)&TestProc32_EndProc, DISCPUMODE_32BIT }, { "64-bit", (uint8_t const *)(uintptr_t)TestProc64, (uintptr_t)&TestProc64_EndProc, DISCPUMODE_64BIT }, }; for (unsigned i = 0; i < RT_ELEMENTS(aSnippets); i++) testDisas(aSnippets[i].pszDesc, aSnippets[i].pbStart, aSnippets[i].uEndPtr, aSnippets[i].enmCpuMode); if (RTTestIErrorCount() == 0) { for (unsigned i = 0; i < RT_ELEMENTS(aSnippets); i++) testPerformance(aSnippets[i].pszDesc, aSnippets[i].pbStart, aSnippets[i].uEndPtr, aSnippets[i].enmCpuMode); } return RTTestSummaryAndDestroy(hTest); }
int main(void) { calculateSmallPrimes(); // Calculate primes smaller than 10^6 to speed up primality test. #ifdef TEST FILE *fp; fp = freopen("solovay_strassen_stats.dat", "w", stdout); long long bit_count, rep; for (bit_count = 1; bit_count <= 9; bit_count++) { // Test bit counts of 2, 4, ..., 256, 512 printf("%d", 1 << bit_count); for (rep = 10; rep <= 100; rep += 10) { long long time = testPerformance(1000, 1 << bit_count, rep); printf(" %lld", time); } printf("\n"); } fclose(fp); return 0; #else mpz_t n; mpz_init(n); printf("N: "); if (mpz_inp_str(n, NULL, BASE) == 0) { printf("ERROR\n"); return -1; } int probably_prime = solovay_strassen(n, REPETITIONS); printf("%s\n", probably_prime? "It's probably prime." : "It's composite."); return 0; #endif }
int main(int argc, char *argv[]) { if (argc != 2) { usage(); } if (strcmp(argv[1], "-c") == 0) { return testCorrectness(); } else if (strcmp(argv[1], "-p") == 0) { return testPerformance(); } else { usage(); return 1; // Never reached. } }