GRASS Programmer's Manual
6.5.svn(2014)-r66266
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
speed3.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 performance comparison between linkm and malloc
10
** I think it better simulates normal use of the library than
11
** speed.c or speed2.c
12
*/
13
#include <stdio.h>
14
#include <grass/linkm.h>
15
16
struct
link
17
{
18
char
let
;
19
struct
link
*
next
;
20
};
21
22
#define LINKM
23
24
int
main
(
int
argc,
char
*argv[])
25
{
26
register
int
i, j;
27
VOID_T
*head;
28
struct
link
List, *tmp, *p;
29
30
31
32
#ifdef LINKM
33
head = (
VOID_T
*)
link_init
(
sizeof
(
struct
link
));
34
#endif
35
36
37
for
(j = 0; j < 1000; j++) {
38
tmp = &List;
39
40
for
(i = 0; i < 2000; i++) {
41
#ifdef LINKM
42
p = (
struct
link
*)
link_new
(head);
43
#else
44
p = (
struct
link
*)
malloc
(
sizeof
(
struct
link
));
45
#endif
46
tmp->
next
= p;
47
tmp = p;
48
tmp->
next
=
NULL
;
49
}
50
51
for
(p = List.
next
; p !=
NULL
;) {
52
tmp = p->
next
;
53
#ifdef LINKM
54
link_dispose
(head, p);
55
#else
56
free
(p);
57
#endif
58
p = tmp;
59
}
60
}
61
62
63
#ifdef LINKM
64
link_cleanup
(head);
65
#endif
66
67
exit(0);
68
}
VOID_T
#define VOID_T
Definition:
qtree.h:17
link_init
struct link_head * link_init(int size)
Definition:
linkm/init.c:40
link_new
struct link_head * link_new(struct link_head *Head)
Definition:
new.c:12
link::next
struct link * next
Definition:
linkm.c:21
link_cleanup
void link_cleanup(struct link_head *Head)
Definition:
linkm/init.c:64
malloc
void * malloc(YYSIZE_T)
link::let
char let
Definition:
linkm.c:20
main
int main(int argc, char *argv[])
Definition:
gem/main.c:302
link_dispose
void link_dispose(struct link_head *Head, VOID_T *ptr)
Definition:
dispose.c:10
NULL
return NULL
Definition:
dbfopen.c:1394
free
void free(void *)
link
Definition:
linkm.c:18
lib
linkm
speed3.c
Generated on Sat Jan 2 2016 01:46:49 for GRASS Programmer's Manual by
1.8.5