~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/linkm/speed2.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
 
3
 
/*
4
 
 **  Written by David Gerdes  US Army Construction Engineering Research Lab
5
 
 **     April 1992
6
 
 **  Copyright 1992 USA-CERL   All rights reserved.
7
 
 **
8
 
 */
9
 
 
10
 
/*
11
 
 **  This is a simple worst case performance comparison between linkm and malloc
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
 
/*
23
 
   #define LINKM
24
 
 */
25
 
 
26
 
int main(int argc, char *argv[])
27
 
{
28
 
    register int i;
29
 
    VOID_T *head;
30
 
    struct link List, *tmp, *p;
31
 
    int rev = 0;
32
 
 
33
 
 
34
 
    tmp = &List;
35
 
 
36
 
#ifdef LINKM
37
 
    /* link_set_chunk_size (2000); */
38
 
    head = (VOID_T *) link_init(sizeof(struct link));
39
 
#endif
40
 
 
41
 
 
42
 
    for (i = 0; i < 2000000; i++) {
43
 
#ifdef LINKM
44
 
        p = (struct link *)link_new(head);
45
 
#else
46
 
        p = (struct link *)malloc(sizeof(struct link));
47
 
#endif
48
 
        tmp->next = p;
49
 
        tmp = p;
50
 
        tmp->next = NULL;
51
 
    }
52
 
 
53
 
    for (p = List.next; p != NULL;) {
54
 
        tmp = p->next;
55
 
#ifdef LINKM
56
 
        link_dispose(head, p);
57
 
#else
58
 
        free(p);
59
 
#endif
60
 
        p = tmp;
61
 
    }
62
 
 
63
 
 
64
 
#ifdef LINKM
65
 
    link_cleanup(head);
66
 
#endif
67
 
 
68
 
    exit(0);
69
 
}