1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
suter [353]
3 years ago
13

Implement a program to measure the impact of application-level buffer sizes on read time. This involves writing to and reading f

rom a large file (say, 2 GB). Vary the application buffer size (say, from 64 bytes to 4 KB). Use timing measurement routines (such as gettimeofday and getitimer on UNIX) to measure the time taken for different buffer sizes. Analyze the results and report your findings: does buffer size make a difference to the overall write time and per-write time?

Computers and Technology
1 answer:
Luda [366]3 years ago
6 0

Answer:

Input file: input.txt

Output file: output.txt

input.txt is a text file of 500 MB.

CODE:

#include <stdio.h>

#include <time.h>

#include <stdlib.h>

#include <fcntl.h>

#include <sys/time.h>

#include <string.h>

#include <unistd.h>

#include <sys/types.h>

double count = 0; // to keep the count of writes

// function which reads from input.txt and writes to output.txt

void fun(int* file_in, int* file_out, int BUFF_SIZE)

{

char *buff = (char *)malloc(BUFF_SIZE*sizeof(char));

while(read(*file_in, buff, BUFF_SIZE) != 0)

{

write(*file_out, buff, strlen(buff));

count++;

}

}

int main(int argc, char* argv[])

{

if(argc == 1)

{

printf("Usage: ./program.c [ buff_size(in bytes) ]\n");

return 0;

}

int file_in,file_out; // input and output file pointers

file_in = open("input.txt",O_RDONLY);

if(file_in == -1)

{

printf("Error while open input.txt \n");

return 0;

}

file_out = open("output.txt",O_WRONLY);

if(file_out == -1)

{

printf("Error occured while opening output.txt\n");

return 0;

}

struct timeval t1, t2; // for capture time

double elapsedTime;

// start timer

gettimeofday(&t1, NULL);

// do something

// ...

fun(&file_in, &file_out, atoi(argv[1]));

// stop timer

gettimeofday(&t2, NULL);

// compute and print the elapsed time in millisec

elapsedTime = (t2.tv_sec - t1.tv_sec)*1000.0; // sec to ms

printf("Overall write time: %lf ms\n",elapsedTime);

printf("Per write time: %lf ms\n", elapsedTime/count);

return 0;

Explanation:

Please see attachment for output

You might be interested in
The term drive app is used to describe applications stored on a computer true or false
Volgvan
Hello <span>Areyano7475
</span>

Question: T<span>he term drive app is used to describe applications stored on a computer true or false


Answer: False


Hope this helps
-Chris</span>
7 0
3 years ago
Read 2 more answers
When Tim Berners-Lee developed the first specifications, protocols, and tools for the World Wide Web in 1993, his employers at C
Svetllana [295]

Answer:

c.

Explanation:

People trust open-source software - if they can see how it works and understand it, they can help improve it and build applications using it. If these protocols were not publicly available - then nobody would have implemented services using them - so nobody would be adopting it.

8 0
3 years ago
A thief has unfortunately captured your atm card number by placing a panel on top of the face of an atm, which was virtually und
Misha Larkins [42]
The item you described is a skimmer it is oftem=n placed and left for an amount of time or watched from afar than when no on is looking they run-up and extract it for its data
3 0
3 years ago
Given numrows and numcols, print a list of all seats in a theater. rows are numbered, columns lettered, as in 1a or 3e. print a
trapecia [35]

/* package whatever; // don't place package name! */

import java.util.*;

import java.lang.*;

import java.io.*;

class NestedLoops {

public static void main (String [] args) {

int numRows = 4;

int numCols = 5;

int i,j;

char ch = 'A';

// Note: You'll need to declare more variables

/* Your solution goes here */

for ( i = 0; i < numRows; i++) { // Outer loop runs for numRows times

for ( j = 0; j < numCols; j++) { // Inner loop runs for numCols times

System.out.print(i+1);

System.out.print((char)(ch+j));

System.out.print(" ");

}

}

System.out.println("");

return;

}

}

8 0
3 years ago
Electronic files created on a computer using programs such as Word software are considered to be _____.documents icons media sav
Rudiy27
Documents. Note that electronic document is a type of media too.
5 0
3 years ago
Other questions:
  • Molly wants to make some cells in her balance spreadsheet different colors so that she can more quickly find important data. Wha
    13·2 answers
  • In microsoft word, when you highlight existing text you want to replace, you’re in
    14·1 answer
  • To illustrate a point in a Word document with a simple chart, what commands should you select?
    8·2 answers
  • A technician is configuring a new SOHO multifunction wireless router at a customer’s location to provide network access to sever
    12·1 answer
  • Select the antonym for given word freedom
    7·2 answers
  • The objects that you place on master pages are called _____.
    6·1 answer
  • Describe all the steps a router goes through while deciding where to send the a packet. Explain why a router would choose one ro
    7·1 answer
  • Website managers use____ every day.
    10·2 answers
  • Calculate The Average of Grades Instructions:
    8·1 answer
  • __________ is a computer tool for evaluating the risk of exposure to wildfires.
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!