58
edits
Changes
→Reference
{{GPU621/DPS921 Index | 20207}}
[mailto:astinziani@myseneca.ca?subject=GPU621 Yuseok Won]
[mailto:astinziani@myseneca.ca?subject=GPU621 Minsu Kim]
[[File:Golang.png|400px|left]] Go Language is a open source programming language that is designed at Google by [https://en.wikipedia.org/wiki/Robert_Griesemer Robert Griesemer], [https://en.wikipedia.org/wiki/Ken_Thompson Ken Thompson], and [https://en.wikipedia.org/wiki/Rob_Pike Rob Pike]. <br>
Go lang is a '''Fast''' and '''Pretty''' language.
GO is used by Google, Youtube, Google Download Server, Uber replaced Node.JS to Go, Twitch's trance-coding process Go & C++.
[[File:what-is-java-5b4bda1cc9e77c0037171617.jpg|400px|left]]
Java is open source and Objectobject-oriented programming language developed by Sun Microsystems in 1995. The founder is James Gosling. In 2010, Oracle acquired Sun Microsystems and owned Java's copyright.
Java is simple programming language, easy to learn, clean and easy to understand. This is because syntax of Java is based on C++ that has removed many confusing and rarely used functionality by user (e.g. operator overloading, explicit pointer, automatic garbage collection manual memory management etc.)
Java is the platform independent language. Programs can run on several different types of computer as long as computer has a Java Runtime Environment(JRE) installed.
<br>
<br>
'''Parallelism and Concurrency'''
diagram cited by Pithikos in [https://stackoverflow.com/questions/1050222/what-is-the-difference-between-concurrency-and-parallelism Stack Overflow]
Go language focuses on concurrency and parallelism by implementing its own Goroutine instead of regular threading. Goroutines uses the built-in scheduler to conduct the threads in behind and hide many complexity of thread management from the user and execute them with “Go” command. Java language can implement thread in two three different methods. The first method is to create a class which extends the “Thread” "Thread" class that gives the user to have control of the lifecycle of the thread. But Java language only allows single inheritance which prevents the thread from being extend extending other base class. The second method is using ‘Runnable’ "Runnable" interface. This method allows to user to extend other base class while still being run as a new thread. However, this method does not give user to control lifecycle of thread.The third, Java version 5.0 and later provides "concurrency" to simplify thread creation and processing. The "[https://docs.oracle.com/javase/tutorial/essential/concurrency/executors.html Executor]" that implement by java.util.concurrent provides APIs for creating and processing new threads. =Implementation===General Implementation Info==
''Before diving into the code, here are some things to know.''
'''1.''' To Increase the accuracy, both Go & Java program will run in terminal using .sh script <br>
- To do this, you will need to enable "Root".<br>''Run below command to start root-user terminal'' sudo -s
'''2.''' To Increase the accuracy, both Go & Java program will run in the same environment/machine <br>
| Machine || Mac Book Pro 2019
|-
| Processor || 2.3GHz 8-core 16 threads Intel Core i9
|-
| macOS || Big Sur 11.5.1
|}
'''3.''' To run both program, 4096 * 4096 pre-generated Matrix with random values between 0 and 1000 will be used <br>
- Create & Download Matrix here [https://onlinenumbertools.com/random-number-matrix https://onlinenumbertools.com/random-number-matrix]
Go to [https://golang.org/dl/ https://golang.org/dl/] & Download Go accordingly to your OS.
package main
runtime.GC()
}
''Above Go code will run in terminal using .sh script.''
#! /bin/sh
echo "Done";
Go to [https://www.java.com/ko/download/manual.jsp https://www.java.com/ko/download/manual.jsp] & Download Java accordingly to your OS. <br>
import java.io.BufferedReader;
import java.io.FileReader;
}
}
''Above Java code will run in terminal using .sh script.''
''' .sh Code to Run Java Program '''
echo "Done";
==Charts==
{| <!-- The nested table must be on a new line -->
| style="border: 2px" |
{| class="wikitable"
|+ Performance difference in Go & Java
|-
| 16 thread|| 14.38 s|| 16.08 s
|}
| style="padding: 15px;" |
[[File:Parallel Programming in Go & Java.png|400px]]
|}
| 2 threads to 4 threads|| 51.90%
|-
| 4 threads to 8 threads|| 49.49%
|-
| 8 threads to 16 threads|| 8.79%
|}
| style="padding: 15px;" |
{| class="wikitable" margin-left: left;|+ Performance increase of difference for Go in comparsion to Java Thread
|-
! !! difference
|-
| Main Thread to 1 thread|| 1020.45%
|-
| 1 threadto 2 threads|| 101127.30%
|-
| 2 thread|| 96.90%|-| threads to 4 threadthreads|| 8193.8012%
|-
| 4 threads to 8 threadthreads|| 5568.27%
|-
| 8 threads to 16 threadthreads|| 12-20.65%
|}
|style="padding: 15px;"|
|}