/[gxemul]/upstream/0.3.6.2/experiments/bintrans_eval.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /upstream/0.3.6.2/experiments/bintrans_eval.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 19 - (hide annotations)
Mon Oct 8 16:19:16 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 2559 byte(s)
0.3.6.2
1 dpavlin 2 /*
2     * Copyright (C) 2004 Anders Gavare. All rights reserved.
3     *
4     * Redistribution and use in source and binary forms, with or without
5     * modification, are permitted provided that the following conditions are met:
6     *
7     * 1. Redistributions of source code must retain the above copyright
8     * notice, this list of conditions and the following disclaimer.
9     * 2. Redistributions in binary form must reproduce the above copyright
10     * notice, this list of conditions and the following disclaimer in the
11     * documentation and/or other materials provided with the distribution.
12     * 3. The name of the author may not be used to endorse or promote products
13     * derived from this software without specific prior written permission.
14     *
15     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16     * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18     * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19     * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20     * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21     * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24     * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25     * SUCH DAMAGE.
26     *
27     *
28     * $Id: bintrans_eval.c,v 1.3 2005/01/09 01:55:27 debug Exp $
29     *
30     * Bintrans algorithm evaluation.
31     */
32    
33     #include <stdio.h>
34     #include <stdlib.h>
35     #include <limits.h>
36     #include <string.h>
37     #include <sys/types.h>
38    
39    
40     int64_t n_instrs = 0;
41     int64_t time_used = 0;
42    
43     int64_t cost_of_interpreted_instruction = 500;
44     int64_t cost_of_native_instruction = 5;
45     int64_t cost_of_translation = 10000;
46    
47    
48     void print_stats(void)
49     {
50     printf("%10lli instructions, time used: %lli\n",
51     (long long)n_instrs, (long long)time_used);
52     }
53    
54    
55     int main(int argc, char *argv[])
56     {
57     FILE *f;
58     int ticks = 0;
59     uint64_t addr;
60     char buf[40];
61    
62     if (argc < 2) {
63     fprintf(stderr, "usage: %s inputfile\n", argv[0]);
64     exit(1);
65     }
66    
67     f = fopen(argv[1], "r");
68     if (f == NULL) {
69     perror(argv[1]);
70     exit(1);
71     }
72    
73     while (!feof(f)) {
74     buf[2] = buf[sizeof(buf)-1] = 0;
75     fgets(buf + 2, sizeof(buf) - 2, f);
76    
77     addr = strtoull(buf, NULL, 0);
78     n_instrs ++;
79    
80     /* TODO */
81    
82     if ((++ ticks) == 100000) {
83     ticks = 0;
84     print_stats();
85     }
86     }
87    
88     print_stats();
89    
90     return 0;
91     }
92    

  ViewVC Help
Powered by ViewVC 1.1.26