Difference between revisions of "ParaCode"

From CDOT Wiki
Jump to: navigation, search
(Project: Grep - Count Keyword in File)
(Assignment 2)
Line 68: Line 68:
  
 
=== Assignment 2 ===
 
=== Assignment 2 ===
 +
 +
We are going to work on 'Grep' project.<br>
 +
 +
Through the profile, we can see that the most cost of the runtime is 'grep()' and 'convert_char_to_string()' functions. As file size growing up, which means more characters in file, the runtime of 'grep()' grows much more faster than the other functions. So we are going to work on 'grep()' function.<br>
 +
 +
Let's going through grep() function:
 +
```
 +
int grep(std::string keyword, std::string input)
 +
{
 +
int counter = 0;
 +
//cout << input << endl;
 +
 +
int keywordLen = keyword.length();
 +
int inputLen = input.length();
 +
char* temp;
 +
temp = new char(keywordLen);
 +
 +
for (int i = 0; i < (inputLen - keywordLen); i++) {
 +
for (int j = 0; j<keywordLen; j++) {
 +
temp[j] = input[i + j];
 +
}
 +
temp[keywordLen] = '\0';
 +
//cout << temp << endl;
 +
if (temp == keyword) {
 +
counter++;
 +
}
 +
}
 +
 +
return counter;
 +
}
 +
```
 +
 
=== Assignment 3 ===
 
=== Assignment 3 ===

Revision as of 22:38, 3 April 2018


GPU610/DPS915 | Student List | Group and Project Index | Student Resources | Glossary

Team Members

  1. Qiliang Chen
  2. Xuan Dinh Truong

Email All

Progress

Assignment 1

Project: LZW Compress

Introduction:

LZW stand for "Lempel–Ziv–Welch". It is a universal lossless data compression algorithm which is widely use in compressing software. It is widely used in image compress and Unix file compress. Here is a project example of LZW compressing written by c++. Here's the link for more details: https://codereview.stackexchange.com/questions/86543/simple-lzw-compression-algorithm

Basic Compile Command:(Linux)

 g++ -std=c++0x lzw.c -o lzw

To Execute Projet

  • Compress file:
 ./lzw -c file.txt
  • Decopress file:
 ./lzw -d file.txt


Profile

We have compress and profile for 3 different size files. The runtime for each is shown below:
Screen Shot 2018-02-23 at 12.55.32 AM.png

To see runtime for each function, see below:
Screen Shot 2018-02-23 at 1.02.40 AM.png

Here is graphic:
Screen Shot 2018-02-23 at 12.42.51 AM.png

Float profile:

Here is the float profile sample for compressing file which has size 54.3MB, float profile is changed to .txt and is simplified)
Screen Shot 2018-02-23 at 1.20.32 AM.png

Project: Grep - Count Keyword in File

Introduction:

On the Linux system, we are very familiar with the Grep command. This is a similar project to that. But this one is more simple. It just counts how many times the keyword appears in the file. After compile the program, we run it as a command like this:
Screen Shot 2018-04-03 at 10.00.32 PM.png

Here, it counts how many 'is' are there in file 'sample.txt'.

Profile: We've make three different sizes of files to profile the program. The runtime of them show below:
Screen Shot 2018-04-03 at 10.11.02 PM.png

To see runtime for functions, see below:
Screen Shot 2018-04-03 at 10.27.19 PM.png

See graphic:
Screen Shot 2018-04-03 at 10.26.29 PM.png

Profile via Visual Studio Sample: NoPara 4023k.JPG

Assignment 2

We are going to work on 'Grep' project.

Through the profile, we can see that the most cost of the runtime is 'grep()' and 'convert_char_to_string()' functions. As file size growing up, which means more characters in file, the runtime of 'grep()' grows much more faster than the other functions. So we are going to work on 'grep()' function.

Let's going through grep() function: ``` int grep(std::string keyword, std::string input) { int counter = 0; //cout << input << endl;

int keywordLen = keyword.length(); int inputLen = input.length(); char* temp; temp = new char(keywordLen);

for (int i = 0; i < (inputLen - keywordLen); i++) { for (int j = 0; j<keywordLen; j++) { temp[j] = input[i + j]; } temp[keywordLen] = '\0'; //cout << temp << endl; if (temp == keyword) { counter++; } }

return counter; } ```

Assignment 3