Commit f650f6ae authored by John Zhang's avatar John Zhang

fix mistake in x label; run quicksort with input size, plot result; inline functions in C quicksort

parent d0277c17
......@@ -320,24 +320,21 @@ def plot(result_dic):
ax.text(width * (i + 1), avg - std_dev, "%.6f" % std_dev, color='#1d1f21', fontweight='bold')
# plt.legend(loc=2)
plt.xticks([width * (i + 1) for i in range(len(targets))], targets)
plt.xticks([width * (i + 1) for i in range(len(targets))], [tgt for (tgt, _, _) in data])
plt.title("%(test_name)s with input size %(input_size)d" % result_dic)
plt.show()
def test_plot():
plot(perf_quicksort(1000, 20))
# import json
# with open('result_quicksort.json', 'r') as fp:
# dic = json.load(fp)
# plot(dic)
if __name__ == '__main__':
import sys
N = int(sys.argv[1])
# fib_res = perf_fibonacci(40, 20)
# save_results('fibonacci', fib_res)
# arraysum_res = perf_arraysum(1000000, 20)
# save_results('arraysum', arraysum_res)
# quicksort_res = perf_quicksort(1000000, 20)
# save_results('quicksort', quicksort_res)
test_functional_quicksort()
quicksort_res = perf_quicksort(N, 100)
save_results('quicksort', quicksort_res)
plot(quicksort_res)
#include <stdint.h>
#include "quicksort.h"
void swap(int64_t* arr, int64_t i, int64_t j) {
static inline void swap(int64_t* arr, int64_t i, int64_t j) {
int64_t t;
t = arr[i];
arr[i] = arr[j];
arr[j] = t;
}
int64_t partition(int64_t* arr, int64_t idx_low, int64_t idx_high) {
static inline int64_t partition(int64_t* arr, int64_t idx_low, int64_t idx_high) {
int64_t pivot, i, j;
pivot = arr[idx_high];
i = idx_low;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment