algorighm/sort/bubble-sort-test.mjs

19 lines
473 B
JavaScript

import { generateRandomArray, measureTime } from '../util/index.mjs';
import {
bubbleSort,
bubbleSort2,
bubbleSort3,
cocktailSort,
} from './bubble-sort.mjs';
const arr = generateRandomArray(10000);
const arr2 = generateRandomArray(10000);
const arr3 = generateRandomArray(10000);
measureTime(bubbleSort, arr);
measureTime(bubbleSort2, arr2);
measureTime(bubbleSort3, arr3);
// 鸡尾酒排序测试
measureTime(cocktailSort, arr);
measureTime(bubbleSort, arr2);