| 782 | } |
| 783 | |
| 784 | BMK_benchOutcome_t BMK_benchFilesAdvanced( |
| 785 | const char* const * fileNamesTable, unsigned nbFiles, |
| 786 | const char* dictFileName, int cLevel, |
| 787 | const ZSTD_compressionParameters* compressionParams, |
| 788 | int displayLevel, const BMK_advancedParams_t* adv) |
| 789 | { |
| 790 | void* srcBuffer = NULL; |
| 791 | size_t benchedSize; |
| 792 | void* dictBuffer = NULL; |
| 793 | size_t dictBufferSize = 0; |
| 794 | size_t* fileSizes = NULL; |
| 795 | BMK_benchOutcome_t res; |
| 796 | U64 const totalSizeToLoad = UTIL_getTotalFileSize(fileNamesTable, nbFiles); |
| 797 | |
| 798 | if (!nbFiles) { |
| 799 | RETURN_ERROR(14, BMK_benchOutcome_t, "No Files to Benchmark"); |
| 800 | } |
| 801 | |
| 802 | if (cLevel > ZSTD_maxCLevel()) { |
| 803 | RETURN_ERROR(15, BMK_benchOutcome_t, "Invalid Compression Level"); |
| 804 | } |
| 805 | |
| 806 | fileSizes = (size_t*)calloc(nbFiles, sizeof(size_t)); |
| 807 | if (!fileSizes) RETURN_ERROR(12, BMK_benchOutcome_t, "not enough memory for fileSizes"); |
| 808 | |
| 809 | /* Load dictionary */ |
| 810 | if (dictFileName != NULL) { |
| 811 | U64 const dictFileSize = UTIL_getFileSize(dictFileName); |
| 812 | if (dictFileSize == UTIL_FILESIZE_UNKNOWN) { |
| 813 | DISPLAYLEVEL(1, "error loading %s : %s \n", dictFileName, strerror(errno)); |
| 814 | free(fileSizes); |
| 815 | RETURN_ERROR(9, BMK_benchOutcome_t, "benchmark aborted"); |
| 816 | } |
| 817 | if (dictFileSize > 64 MB) { |
| 818 | free(fileSizes); |
| 819 | RETURN_ERROR(10, BMK_benchOutcome_t, "dictionary file %s too large", dictFileName); |
| 820 | } |
| 821 | dictBufferSize = (size_t)dictFileSize; |
| 822 | dictBuffer = malloc(dictBufferSize); |
| 823 | if (dictBuffer==NULL) { |
| 824 | free(fileSizes); |
| 825 | RETURN_ERROR(11, BMK_benchOutcome_t, "not enough memory for dictionary (%u bytes)", |
| 826 | (unsigned)dictBufferSize); |
| 827 | } |
| 828 | |
| 829 | { int const errorCode = BMK_loadFiles(dictBuffer, dictBufferSize, |
| 830 | fileSizes, &dictFileName /*?*/, |
| 831 | 1 /*?*/, displayLevel); |
| 832 | if (errorCode) { |
| 833 | res = BMK_benchOutcome_error(); |
| 834 | goto _cleanUp; |
| 835 | } } |
| 836 | } |
| 837 | |
| 838 | /* Memory allocation & restrictions */ |
| 839 | benchedSize = BMK_findMaxMem(totalSizeToLoad * 3) / 3; |
| 840 | if ((U64)benchedSize > totalSizeToLoad) benchedSize = (size_t)totalSizeToLoad; |
| 841 | if (benchedSize < totalSizeToLoad) |
no test coverage detected