GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
speed.c
Go to the documentation of this file.
1 /*
2  ** Written by David Gerdes US Army Construction Engineering Research Lab
3  ** April 1992
4  ** Copyright 1992 USA-CERL All rights reserved.
5  **
6  */
7 
8 /*
9  ** This is a simple best case performance comparison between linkm and malloc
10  */
11 #include <stdio.h>
12 #include <grass/linkm.h>
13 
14 struct link
15 {
16  char let;
17  struct link *next;
18 };
19 
20 /*
21  #define LINKM
22  */
23 
24 int main(int argc, char *argv[])
25 {
26  register int i;
27  VOID_T *head;
28  struct link List, *tmp, *p;
29  int rev = 0;
30 
31 
32 
33 #ifdef LINKM
34  head = (VOID_T *) link_init(sizeof(struct link));
35 #endif
36 
37 
38  for (i = 0; i < 2000000; i++) {
39 #ifdef LINKM
40  p = (struct link *)link_new(head);
41  link_dispose(head, p);
42 #else
43  p = (struct link *)malloc(sizeof(struct link));
44  free(p);
45 #endif
46  }
47 
48 #ifdef LINKM
49  link_cleanup(head);
50 #endif
51 
52  exit(0);
53 }
#define VOID_T
Definition: qtree.h:17
struct link_head * link_init(int size)
Definition: linkm/init.c:40
struct link_head * link_new(struct link_head *Head)
Definition: new.c:12
void link_cleanup(struct link_head *Head)
Definition: linkm/init.c:64
void * malloc(YYSIZE_T)
int main(int argc, char *argv[])
Definition: gem/main.c:302
void link_dispose(struct link_head *Head, VOID_T *ptr)
Definition: dispose.c:10
void free(void *)