~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to util/bench/ben_write.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* @(#)ben_write.c      19.1 (ES0-DMD) 02/25/03 14:35:21 */
 
2
/*===========================================================================
 
3
  Copyright (C) 1995 European Southern Observatory (ESO)
 
4
 
 
5
  This program is free software; you can redistribute it and/or 
 
6
  modify it under the terms of the GNU General Public License as 
 
7
  published by the Free Software Foundation; either version 2 of 
 
8
  the License, or (at your option) any later version.
 
9
 
 
10
  This program is distributed in the hope that it will be useful,
 
11
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
  GNU General Public License for more details.
 
14
 
 
15
  You should have received a copy of the GNU General Public 
 
16
  License along with this program; if not, write to the Free 
 
17
  Software Foundation, Inc., 675 Massachusetss Ave, Cambridge, 
 
18
  MA 02139, USA.
 
19
 
 
20
  Corresponding concerning ESO-MIDAS should be addressed as follows:
 
21
        Internet e-mail: midas@eso.org
 
22
        Postal address: European Southern Observatory
 
23
                        Data Management Division 
 
24
                        Karl-Schwarzschild-Strasse 2
 
25
                        D 85748 Garching bei Muenchen 
 
26
                        GERMANY
 
27
===========================================================================*/
 
28
 
 
29
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
30
.TYPE        Module
 
31
.NAME        ben_write
 
32
.LANGUAGE    C
 
33
.AUTHOR      CARLOS GUIRAO- IPG-ESO Garching
 
34
.CATEGORY    OS benchmarks. Disk write benchmark.
 
35
.COMMENTS    This benchmark checks the disk write time through
 
36
             the os interface.
 
37
 
 
38
.REMARKS     This benchmark must run before running the ben_dread
 
39
             benchmark.
 
40
.REMARKS     This benchmarck is included in the shell script: "brun".
 
41
.REMARKS     Use the "make" command to update the benchmark. 
 
42
.VERSION     1.0 10-Feb-1988   Implementation     CGS
 
43
------------------------------------------------------------*/
 
44
#include <osparms.h>
 
45
 
 
46
#ifdef ERRNO
 
47
extern int oserror;
 
48
#else
 
49
#define ERRNO
 
50
int oserror;
 
51
#endif
 
52
 
 
53
/* #define BLOCKS 256 */
 
54
#define BLOCKS 10000            
 
55
#define BLKSIZE 2048
 
56
/* Size File: BLOCKS*BLKSIZE 10000*2048 = 20MBytes */ 
 
57
 
 
58
main(argc,argv)
 
59
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
60
.PURPOSE     Write data on disc.
 
61
.RETURNS     Upon succesful execution of the command 0 status is
 
62
             returned, or 1 in case of error.
 
63
.REMARKS     This benchmark must run before running the ben_rread
 
64
             o ben_sread benchmark.
 
65
.REMARKS     System dependencies:
 
66
             OS: osfcreate(), osdopen(), osdclose(), osdwrite();
 
67
------------------------------------------------------------------*/
 
68
int argc;
 
69
char **argv;
 
70
{
 
71
        int osfcreate(), osdopen(), osdclose();
 
72
        long osdwrite();
 
73
 
 
74
        char buffer[BLKSIZE];
 
75
        register int i;
 
76
        int fildes;
 
77
 
 
78
        if (argc < 2) {
 
79
                printf("Usage: %s filename\n",argv[0]);
 
80
                ospexit(1);
 
81
                }
 
82
 
 
83
        if (osfcreate(argv[1], sizeof(buffer)*BLOCKS, 0640) < 0) {
 
84
                printf("OSFCREATE FAILED.\n");
 
85
                ospexit(1);
 
86
                }
 
87
        else {
 
88
                if ((fildes = osdopen(argv[1],READ_WRITE)) < 0) {
 
89
                        printf("OSDOPEN FAILED.\n");
 
90
                        ospexit(1);
 
91
                        }
 
92
                }
 
93
 
 
94
        for (i=0 ; i<BLOCKS; i++) {
 
95
                if (osdwrite(fildes, buffer, sizeof(buffer)) < 0) {
 
96
                        printf("OSDWRITE FAILED BLOCK %d\n",i);
 
97
                        ospexit(1);
 
98
                        }
 
99
                }
 
100
 
 
101
        if (fsync(fildes) < 0) {
 
102
                printf("FSYNC FAILED.\n");
 
103
                ospexit(1);
 
104
                }
 
105
 
 
106
        if (osdclose(fildes) < 0) {
 
107
                printf("OSDCLOSE FAILED.\n");
 
108
                ospexit(1);
 
109
                }
 
110
 
 
111
        ospexit(0);
 
112
}