Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- #include "queue.h"
- #define MAX 10000
- char * randomString (int size ) {
- int i ;
- char * str = ( char *) malloc (( size +1)* sizeof ( char ));
- for ( i = 0 ; i < size ; ++ i ) {
- str [ i ] = ( rand () % 26) + 'A';
- }
- str [ size ] = '\0 ';
- return str ;
- }//vorgegeben um einen zufälligen String zu kreieren
- int main() {
- int i ;
- char * strings [ MAX ];
- clock_t tic , toc ; //Zeit
- srand ( time ( NULL ));
- for ( i = 0 ; i < MAX ; ++ i ) {
- strings [ i ] = randomString (8);
- }
- priorityqueue_t * pq = pqueue_create ();
- tic = clock ();
- for ( i = 0 ; i < MAX ; ++ i ) {
- pqueue_insert ( pq , strings [ i ] , rand () % 100);
- }
- toc = clock ();
- // pqueue_print(pq); //Gib die Liste aus
- printf (" insertion time : %f\n", ( float )( toc - tic ) / CLOCKS_PER_SEC );
- tic = clock ();
- for ( i = 0 ; i < MAX ; ++ i ) {
- pqueue_extractMinimum( pq );
- }
- toc = clock ();
- printf (" extract time : %f\n", ( float )( toc - tic ) / CLOCKS_PER_SEC );
- for ( i = 0 ; i < MAX ; ++ i ) {
- free ( strings [ i ]);
- }
- pqueue_destroy ( pq );
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement