1. Andrew Schein
  2. usort

Commits

asc...@andrewschein.com  committed 07eafaf

removed some stuff.

  • Participants
  • Parent commits 2cdbe9d
  • Branches default

Comments (0)

Files changed (15)

File qsort/Makefile

View file
 cmp   : all
 	cd t ; ./cmp-all.sh
 
-sample : 
-	rm -f code_sample.*
-	echo "*.back*\n.tar_ignore\n*3way*\n*.hg*" > .tar_ignore
-	tar -hX .tar_ignore -cf code_sample.tar *
-	gzip code_sample.tar
-	rm -f .tar_ignore

File qsort/t/.back/Makefile~

-include ../defs.mk
-
-APPS=u1 s1 u2 s2 f4 f8 u4 s4 u8 s8
-SRC=$(patsubst %,%.c,$(wildcard $(APPS)))
-
-all : $(APPS)
-	echo $(SRC)
-
-#qsort-cmp : qsort-cmp.c ../swap.c ../qsort.c
-#	gcc -g  $(W) $(I) $(O) -o qsort-cmp qsort-cmp.c
-
-u1  : qsort-cmp.c ../swap.c ../qsort.c $(SRC)  
-	gcc $(G) $(W) $(I) $(O) -o u1 u1.c 
-
-s1  : qsort-cmp.c ../swap.c ../qsort.c  $(SRC)
-	gcc $(G) $(W) $(I) $(O) -o s1 s1.c 
-
-u2  : qsort-cmp.c ../swap.c ../qsort.c  $(SRC)
-	gcc $(G) $(W) $(I) $(O) -o u2 u2.c 
-
-s2  : qsort-cmp.c ../swap.c ../qsort.c  $(SRC)
-	gcc $(G) $(W) $(I) $(O) -o s2 s2.c 
-
-f4  : qsort-cmp.c ../swap.c ../qsort.c  $(SRC)
-	gcc $(G) $(W) $(I) $(O) -o f4 f4.c 
-
-s4  : qsort-cmp.c ../swap.c ../qsort.c  $(SRC)
-	gcc $(G) $(W) $(I) $(O) -o s4 s4.c 
-
-u4  : qsort-cmp.c ../swap.c ../qsort.c  $(SRC)
-	gcc $(G) $(W) $(I) $(O) -o u4 u4.c 
-
-f8  : qsort-cmp.c ../swap.c ../qsort.c  $(SRC)
-	gcc $(G) $(W) $(I) $(O) -o f8 f8.c 
-
-u8  : qsort-cmp.c ../swap.c ../qsort.c  $(SRC)
-	gcc $(G) $(W) $(I) $(O) -o u8 u8.c 
-
-s8  : qsort-cmp.c ../swap.c ../qsort.c  $(SRC)
-	gcc $(G) $(W) $(I) $(O) -o s8 s8.c 
-
-
-#s2-qsort-cmp : s2-qsort-cmp.c ../swap.c ../qsort.c
-#	gcc -g  $(W) $(I) $(O)  -o s2-qsort-cmp s2-qsort-cmp.c
-
-#qsort-3way-cmp : qsort-3way-cmp.c swap.c qsort.c
-#gcc -g  $(W) $(I) $(O) -o qsort-3way-cmp qsort-3way-cmp.c
-
-clean :
-	rm -f $(APPS) qsort-cmp # qsort-3way-cmp 

File qsort/t/.back/cmp-all.sh~

-#!/bin/sh -e
-
-apps="u1 s1 u2 s2 u4 s4 f4 f8"
-
-for app in $apps ; do
-    export app
-    ./cmp.sh
-done
-

File qsort/t/.back/cmp.sh~

-#!/usr/bin/zsh -e
-
-echo "TESTING APP: " ${app:="f8"}
-APP=$app
-
-i=(10 100 1000 10000 100000 1000000 10000000 100000000 )
-t[0]=10000000
-t[1]=1000000
-t[2]=100000
-t[3]=10000
-t[4]=1000
-t[5]=100
-t[6]=10
-t[7]=3
-t[8]=1
-sz=${#i[@]}
-c=1
-echo "Sort Comparison of unsigned integers on N numbers generating according to:"
-echo "RANDOM:    random integers"
-echo "BOUNDED:   random() % (N/4)"
-echo "SORTED:    sorted integers 1...N"
-echo "REVERSED:  sorted integers N...1"
-echo "IDENT:     all values of the array are \"1\""
-
-echo "\nRANDOM"
-echo "N               mysort (secs)   GLIBC (secs)    %impr"
-c=1
-while [ $c -lt $sz ] ; do
-    ./${APP} ${i[$c]} RAND ${t[$c]}  
-    c=$(( $c + 1 ))
-done;
-if [ ! $app = "f4" -a ! $app = "f8" ] ; then
-    echo "BOUNDED"
-    c=1
-    while [ $c -lt $sz ] ; do
-        ./${APP} ${i[$c]} BOUNDED ${t[$c]}  
-        c=$(( $c + 1 ))
-    done;
-fi;
-echo "SORTED"
-c=1
-while [ $c -lt $sz ] ; do
-    ./${APP} ${i[$c]} SORTED ${t[$c]}  
-    c=$(( $c + 1 ))
-done;
-echo "REVERSED"
-c=1
-while [ $c -lt $sz ] ; do
-    ./${APP} ${i[$c]} REVERSE ${t[$c]}  
-    c=$(( $c + 1 ))
-done;
-echo "IDENT"
-c=1
-while [ $c -lt $sz ] ; do
-    ./${APP} ${i[$c]} IDENT ${t[$c]}  
-    c=$(( $c + 1 ))
-done;

File qsort/t/.back/f4.c~

-#include <math.h>
-#define ISNAN(x)  isnan((x))
-#define TY float
-#define TY_FMT "%f"
-#include "../ufunc/f4_sort.c"
-#define QS f4_sort
-#include "qsort-cmp.c"

File qsort/t/.back/f8.c~

-#include <math.h>
-#define ISNAN(x)  isnan((x))
-#define TY double
-#define TY_FMT "%lf"
-#include "../ufunc/f8_sort.c"
-#define QS f8_sort
-#include "qsort-cmp.c"

File qsort/t/.back/qsort-cmp.c~

-/* Test harness for qsort.c, useful for all C base types up to 64 bits.  
-   Uses macros for polymorphism.
-   To use, define macro TY (e.g. #define TY float) then #include this file. */
-
-#ifndef QSORT_CMP
-#define QSORT_CMP
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include <string.h>
-#include <sys/time.h>
-#include "datetime/TIME.c"
-#include <unistd.h>
-#ifndef ISNAN
-#define CHECKNAN(x) (x)
-#else 
-#define CHECKNAN(x) (ISNAN((x)) ? 0 : (x)) 
-#endif
-
-enum generator {RAND,BOUNDED,SORTED, REVERSE ,IDENT} ;
-
-long long k,j;
-const char* usage="qsort-cmp dist N trials\n"
-"dist is one of: RAND, BOUNDED , SORTED, REVSORTED, IDENT\n"
-"N:              size of the array.\n"
-"trials:         how many trials to do.  Necessary for small N.\n";
-
-int parseDist(char* dist_str) {
-    if (!strcmp("BOUNDED",dist_str)) 
-        return BOUNDED;
-    else if (!strcmp("RAND",dist_str)) 
-        return RAND;
-    else if (!strcmp("SORTED",dist_str))
-        return SORTED;
-    else if (!strcmp("REVERSE",dist_str))
-        return REVERSE;
-    else if (!strcmp("IDENT",dist_str))
-        return IDENT;
-    else fprintf(stderr,"dist argument mismatch.\n%s\n",usage),exit(1);
-}
-
-void randomized(TY *x, long long n) {
-    long long i; 
-    union { char l[8]; TY t; } u;
-    for (i = 0; i < n; i++) {
-        u.l[0] =  random();
-        u.l[1] =  random();
-        u.l[2] =  random();
-        u.l[3] =  random();
-	u.l[4] =  random();
-        u.l[5] =  random();
-        u.l[6] =  random();
-        u.l[7] =  random();
-        
-	x[i]   =  u.t; 
-        x[i]   =  CHECKNAN(x[i]);
-    }
-}
-
-void bounded(TY *x, long long n) {
-    long long i;
-    union { long l[2]; TY t;} u;
-    for (i = 0; i < n; i++) {
-        u.l[0] = (random() % (n/4));
-        u.l[1] = (random() % (n/4));
-        x[i]   = u.t;
-        x[i]   = CHECKNAN(x[i]);
-    }
-}
-
-void identity(TY *x, long long n) {
-    long long i;
-    for (i = 0; i < n; i++) {
-        x[i] = 1;
-    }
-}
-
-void reverse(TY *x, long long n) {
-    long long i;
-    for (i = 0; i < n; i++) 
-        x[i] = n - i - 1;
-}
-
-void sorted(TY *x, long long n) {
-    long long i;
-    for (i = 0; i < n; i++) 
-        x[i] = i;
-}
-
-int compare(const void *a, const void *b) {
-    TY A = *(const TY *)a, B = *(const TY *)b;
-    if (A > B) return 1;
-    if (B < A) return -1;
-    return 0;
-}
-
-void fill(char* dist, TY* array1,long n) {
-    switch (parseDist(dist)) {
-    case RAND : 
-        randomized(array1,n) ; break;
-    case BOUNDED :
-        bounded(array1,n) ;    break;
-    case SORTED :
-        sorted(array1,n)  ;    break;
-    case REVERSE :
-        reverse(array1,n) ;    break;
-    case IDENT :
-        identity(array1,n) ;    break;
-    default :
-        fprintf(stderr,"dist match error.\n"), exit(1);
-    }
-}
-
-void checkWork(const char *name, TY *a, long long n ) {
-    long long i,j;
-    for (i = 1; i < n; i++) {
-        if (a[i-1] > a[i]) {
-            fprintf (stderr,"%s: %lld x %zd: failure at offset %lld\n", name, n,
-                     sizeof(TY), i);
-            for (j=0; j < n;j++)
-                fprintf(stderr,TY_FMT " ",a[j]);
-            fprintf(stderr,"\n"); 
-            free(a);
-            exit(1);
-        }
-    }
-}
-
-int main (int argc, char **argv)
-{
-    if (argc < 4) fprintf(stderr,"too few arguments: %d\n%s",argc,usage) , exit(1);
-    long i=j=0; long n=strtoul(argv[1],NULL,10);
-    long num_trials = strtoul(argv[3],NULL,10);
-    double start, end, m_tot=0, g_tot=0;
-    TY *array1 = (TY*) malloc (n * sizeof(TY));
-    if (array1 == NULL)
-        {
-            fprintf (stderr,"%d x %d: no memory\n", argc, sizeof(TY));
-            return 1;
-        }
-    if (getenv("SEED")) srand(time(NULL)); /* default is debugging mode. */
-    for (i = 0; i < num_trials; i++) {
-        fill(argv[2],array1,n);
-        start = TIME();
-        qsort (array1,n,sizeof(TY),&compare);
-        end   = TIME();
-        if (i) {
-            g_tot += end-start;
-        }  
-        checkWork("GNU",array1,n);
-    }
-    g_tot /= (double) (num_trials - 1);
-    
-    
-    for (i = 0; i < num_trials; i++) {
-        fill(argv[2],array1,n);
-        start = TIME();
-        QS(array1,n);
-        end   = TIME();
-        if (i) {
-            m_tot += end - start;
-        }    
-        checkWork("schein",array1,n);
-    
-    }
-    m_tot /= (double) (num_trials - 1);
-    
-        
-    
-    fprintf(stdout,"%10ld\t%5.10f\t%5.10f\t%2.2f\n",n,m_tot,g_tot,
-            100*((g_tot/m_tot) - 1));
-    free (array1);
-    return 0; 
-}
-#endif
-
-
-
-
-

File qsort/t/.back/s1.c~

-
-#define TY signed char
-#define TY_FMT "%c"
-#include "../ufunc/s1_sort.c"
-#define QS s1_sort
-#include "qsort-cmp.c"

File qsort/t/.back/s2.c~

-
-#define TY short
-#define TY_FMT "%i"
-#include "../ufunc/s2_sort.c"
-#define QS s2_sort
-#include "qsort-cmp.c"

File qsort/t/.back/s4.c~

-#define TY long
-#define TY_FMT "%ld"
-#include "../ufunc/s4_sort.c"
-#define QS s4_sort
-#include "qsort-cmp.c"

File qsort/t/.back/s8.c~

-#define TY long long
-#define TY_FMT "%lld"
-#include "../ufunc/s8_sort.c"
-#define QS s8_sort
-#include "qsort-cmp.c"

File qsort/t/.back/u1.c~

-
-#define TY unsigned char
-#define TY_FMT "%d"
-#include "../ufunc/u1_sort.c"
-#define QS u1_sort
-#include "qsort-cmp.c"
-
-

File qsort/t/.back/u2.c~

-
-#define TY unsigned short
-#define TY_FMT "%ui"
-#include "../ufunc/u2_sort.c"
-#define QS u2_sort
-#include "qsort-cmp.c"

File qsort/t/.back/u4.c~

-#define TY uint32_t
-#define TY_FMT "%u"
-#include "../ufunc/u4_qsort.c"
-#define QS u4_qsort
-#include "qsort-cmp.c"
-

File qsort/t/.back/u8.c~

-#define TY unsigned long long
-#define TY_FMT "%llu"
-#include "../ufunc/u8_sort.c"
-#define QS u8_sort
-#include "qsort-cmp.c"