Sponsored Content
Top Forums Shell Programming and Scripting script to add numbers is slow Post 302300316 by CRGreathouse on Monday 23rd of March 2009 09:10:19 PM
Old 03-23-2009
Lightbulb

That is an improvement. I timed it at 2m13.027s doing 5000x5000. But there's a tenfold improvement with a direct translation to C (11.885s):
Code:
#include <stdio.h>

main(int argc, char *argv[])
{
    int height = atoi(argv[1]);
    int width = atoi(argv[2]);
    int i = width * height - width - 1;
    int k = width - 1;
    int j;
    for (j = 0; j < i; j++) {
        if (j == k) {
            //printf("%i\n", k + width);
        } else {
            int tmp = j + width;
            printf("4 %i %i %i %i\n", j, j + 1, tmp + 1, tmp);
        }
    }
    return 0;
}

An optimized version might be even better.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

My script runs too slow :-(...

Hello experts, I have a series issue in script that result with bad peformence and I wonder if you can assist me. For example I have two files: File-New, size 15Mb. File-Old, size 1Mb. File-New content: a b c k File-Old content: d f a b (0 Replies)
Discussion started by: roybe
0 Replies

2. Shell Programming and Scripting

add numbers in shell script

cat dailyreports | grep "Important list" | awk -F":" '{print $2}' | awk -F" " '{print $1}' hey guys, after running the above combination of cat and awk, i get the below output: 3 4 2 9 now, i need to add these numbers up all in one line. i dont know what to add to that cat and awk one... (2 Replies)
Discussion started by: Terrible
2 Replies

3. Shell Programming and Scripting

Bash script too slow

I have a bash script that will take approx. 130 days to complete. I am trying to grep a list of 1,144 user ID's out of 41 (1 GB each) files. The 41 files were originally one 41 G file, but that was horrendously too slow.:eek: This is my current file: #!/bin/bash for i in `cat... (11 Replies)
Discussion started by: tigta09
11 Replies

4. Shell Programming and Scripting

Slow Perl script: how to speed up?

I had written a perl script to compare two files: new and master and get the output of the first file i.e. the first file: words that are not in the master file STRUCTURE OF THE TWO FILES The first file is a series of names ramesh sushil jonga sudesh lugdi whereas the second file (could be... (4 Replies)
Discussion started by: gimley
4 Replies

5. UNIX for Dummies Questions & Answers

Help with slow KSH script

My script builds a lot of these array lists, then compares their sizes which solves my problem, but runs very slow. :( set -A comboSorted -- $( for x in ${IDs} do nawk -v s=$x ' BEGIN { testPattern="^" s "$" } { if ( $2 ~ testPattern ) { getline;getline; if ($1 == "IMAGE_SIZE") print... (1 Reply)
Discussion started by: nerdcurious
1 Replies

6. Shell Programming and Scripting

Slow Script Execution.

Basically my requirement is to know the total number of free anonymous ports. anonymous port range is 32768- 65535. i wrote a script for that ********************************************** for i in {32768..65535} do netstat -an | grep $i > /dev/null if ... (21 Replies)
Discussion started by: mohtashims
21 Replies

7. Shell Programming and Scripting

Slow down output from dhclient-script to screen

Hi I know the basic about script and sleep processes. However this is more tricky: I would like to run sh -x /sbin/dhclient-script and slow down the output of the script as a whole. How would you do it? I would like to delay output on the screen with 1 second for every line for the output... (3 Replies)
Discussion started by: medium_linux
3 Replies

8. Shell Programming and Scripting

Script to alert about a slow link on the website

Hello all, Currently I am using a script with "curl" to get the an alert if 200 ok would not be grepped.and the link is down. is it possible to get an alert mail if a particular link on a website is not completely down but SLOW?? (0 Replies)
Discussion started by: chirag991
0 Replies

9. Shell Programming and Scripting

Shell script reading file slow

I have shell program as below #!/bin/sh echo ======= LogManageri start ========== #This directory is getting the raw data from remote server Raw_data=/opt/ftplogs # This directory is ready for process the data Processing_dir=/opt/processing_dir # This directory is prcoessed files and... (4 Replies)
Discussion started by: Chenchireddy
4 Replies

10. Shell Programming and Scripting

Improve script - slow process with big files

Gents, Please can u help me to improve this script to be more faster, it works perfectly but for big files take a lot time to end the job.. I see the problem is in the step (while) and in this part the script takes a lot time.. Please if you can find a best way to do will be great. ... (13 Replies)
Discussion started by: jiam912
13 Replies
GLVIEWPORT(3G)							    OpenGL 3.3							    GLVIEWPORT(3G)

NAME
glViewport - set the viewport C SPECIFICATION
void glViewport(GLint x, GLint y, GLsizei width, GLsizei height); PARAMETERS
x, y Specify the lower left corner of the viewport rectangle, in pixels. The initial value is (0,0). width, height Specify the width and height of the viewport. When a GL context is first attached to a window, width and height are set to the dimensions of that window. DESCRIPTION
glViewport specifies the affine transformation of x and y from normalized device coordinates to window coordinates. Let x nd y nd be normalized device coordinates. Then the window coordinates x w y w are computed as follows: x w = x nd + 1 width 2 + x y w = y nd + 1 height 2 + y Viewport width and height are silently clamped to a range that depends on the implementation. To query this range, call glGet() with argument GL_MAX_VIEWPORT_DIMS. ERRORS
GL_INVALID_VALUE is generated if either width or height is negative. ASSOCIATED GETS
glGet() with argument GL_VIEWPORT glGet() with argument GL_MAX_VIEWPORT_DIMS SEE ALSO
glDepthRange() COPYRIGHT
Copyright (C) 1991-2006 Silicon Graphics, Inc. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/. OpenGL 3.3 03/08/2011 GLVIEWPORT(3G)
All times are GMT -4. The time now is 05:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy