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
Were Al Zink’s actions that of someone trying to be an invisible Sponsor
AlexFokin [52]
Al Zink actions differentiate him as trying to take an invisible role as a project sponsor. That is, Al Zink does not do his chosen role and accountability as the lead project sponsor. Though, in dissimilar occasions, Al Zink is seen to evade making a serious choice regarding the development of the project. Consequently, as a project sponsor, it is his accountability to deliver clear steps in increasing the project, recover every step of project development and balance the start of the project. 
7 0
3 years ago
Any two differences between third and fourth generation of computer
Setler [38]

Answer:

Third generation computer use integrated circuit(IC) and it was fast and reliable.

Forth generation computer micro computer were introduced and they were highly reliable and fast.

5 0
2 years ago
Read 2 more answers
A computer system designed to run games is called a
Maru [420]

A computer system designed to run games is called a game console.

3 0
3 years ago
Read 2 more answers
STATE THE MODULES THAT ARE INCLUDED WHEN LEARNING CALCULUS.
Rzqust [24]

Answer:

Calculus is a branch of mathematics focused on limits, functions, derivatives, integrals, and infinite series. ... Calculus has widespread applications in science, economics, and engineering and can solve many problems for which algebra alone is insufficient.

7 0
2 years ago
You are the network administrator for a company. The company's policy is that the users are allowed to set their own passwords b
insens350 [35]

After I have changed her password, all I will need to do is select the “User must change password at next logon” option. This option will prompt her to log on to her PC using the password I assigned to her.

Explanation

An active Directory on most Domain Controllers gives you access to add users, disable accounts, change password, and various other tasks. Assuming that everything is setup, I am just going to go to my Windows Server Manager dashboard of my Domain Controller. While I am at my dashboard, I will click on tools and then drop down to the Active Directory Users and Computers to locate my desired user who seems to have been locked out.

Once the user has been identified, I will simply need to right click on the account and select “reset password”. A small dialog box with a list of cool security options will pop up. I will be required to reset it to something simple and default and make sure to select the “User must change password at next logon” option.

What this means is that the user who is locked out, upon logging back in, will be prompted to enter the password I gave them first as default but then will immediately be asked to change the password to something new. We do not see options A and B a lot in the real world. It is best practice not to select these options

Learn more about Active Directory

brainly.com/question/13615178

brainly.com/question/13591643

#LearnWithBrainly

5 0
3 years ago
Other questions:
  • Which of the following best explains why some people invest their saving in the stock market and others put their saving in bank
    5·2 answers
  • LOOK TO THE LEFT AND RIGHT BEFORE ENTERING ANY INTERSECTION ON A GREEN LIGHT BECAUSE:
    12·2 answers
  • A general rule for adding text to a slide is ____.
    8·2 answers
  • How often are computer and user policies applied after a user has logged into a computer?
    15·1 answer
  • On most computers, the default font size in Word is ____. 8 11 14 16
    6·1 answer
  • The individual accountable for ensuring the day-to-day operation of the InfoSec program, accomplishing the objectives identified
    7·1 answer
  • Number are stored and transmitted inside a computer in the form of​
    6·1 answer
  • How do i use a computer (i'm 99999 years old)
    8·2 answers
  • what is example of application of machine learning that can be imposed in eduction. (except brainly.)
    9·1 answer
  • As part of your regular system maintenance, you install the latest operating system updates on your Windows 10 computer. After s
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!