Changes and additional files for RMI profiling
authorrtrimana <rtrimana@uci.edu>
Mon, 24 Apr 2017 23:06:22 +0000 (16:06 -0700)
committerrtrimana <rtrimana@uci.edu>
Mon, 24 Apr 2017 23:06:22 +0000 (16:06 -0700)
12 files changed:
benchmarks/Java/Lifxtest/Lifxtest.java
iotjava/Makefile
iotjava/iotrmi/C++/basics/TestClassComplete_Stub.cpp
iotjava/iotrmi/C++/basics/TestClassInterface_Skeleton.cpp
iotjava/iotrmi/C++/basics/TestClassProfiling.hpp [new file with mode: 0644]
iotjava/iotrmi/C++/basics/TestClass_Skeleton.cpp
iotjava/iotrmi/Java/basics/TestClass.java
iotjava/iotrmi/Java/basics/TestClassProfiling.java [new file with mode: 0644]
iotjava/iotrmi/Java/basics/TestClass_ProfilingStub.java [new file with mode: 0644]
iotjava/iotrmi/Java/basics/TestClass_Skeleton.java
localconfig/iotpolicy/development/testclasspolicy_profiling.pol [new file with mode: 0644]
localconfig/iotpolicy/development/testclassrequires_profiling.pol [new file with mode: 0644]

index 97860552ec9917ca46c9a107a2defe39f31d639d..1c307147389e7f49d8016b2bd40723278c5e9dfa 100644 (file)
@@ -44,6 +44,7 @@ public class Lifxtest {
                                Thread.sleep(1000);
                        }
 
+
                        for (int i = 2500; i < 9000; i += 100) {
                                System.out.println("Adjusting Temp: " + Integer.toString(i));
                                lifx.setTemperature(i);
index e44a4ba24562f81b2e1d83b610184f54e3fee537..2ff4d533548ae82e5d3330272b8004546f6c23b1 100644 (file)
@@ -22,10 +22,11 @@ compiler:
 PHONY += run-compiler-dev
 run-compiler-dev:
        cp ../localconfig/iotpolicy/development/*.pol $(BIN_DIR)/iotpolicy/
-       #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler testclasspolicy.pol testclassrequires.pol callbackpolicy.pol callbackrequires.pol -cplus Cplus -java Java
+       #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler testclasspolicy_profiling.pol testclassrequires_profiling.pol -cplus Cplus -java Java
+       cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler testclasspolicy.pol testclassrequires.pol callbackpolicy.pol callbackrequires.pol -cplus Cplus -java Java
        #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler callbackpolicy.pol callbackrequires.pol testclasspolicy_advanced.pol testclassrequires_advanced.pol -cplus Cplus -java Java
        #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler callbackpolicy.pol callbackrequires.pol testclasspolicy_callbacks.pol testclassrequires_callbacks.pol -cplus Cplus -java Java
-       cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler testclasspolicy_callbacks.pol testclassrequires_callbacks.pol callbackpolicy.pol callbackrequires.pol -cplus Cplus -java Java
+       #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler testclasspolicy_callbacks.pol testclassrequires_callbacks.pol callbackpolicy.pol callbackrequires.pol -cplus Cplus -java Java
        #cd $(BIN_DIR)/iotpolicy; $(JAVA) -cp .:..:../$(PARSERJARS):../$(BIN_DIR) iotpolicy.IoTCompiler testclasspolicy_callbacks_three.pol testclassrequires_callbacks_three.pol callbackpolicy.pol callbackrequires.pol callbackpolicy_two.pol callbackrequires_two.pol -cplus Cplus -java Java
 
 
@@ -139,18 +140,19 @@ compile:
        #cp ./iotrmi/C++/basics/* $(BIN_DIR)/iotpolicy/output_files/Cplus
        cd $(BIN_DIR)/iotpolicy/output_files; cp *.java ./Java
        cd $(BIN_DIR)/iotpolicy/output_files; cp *.hpp ./Cplus
-       #cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClass_Skeleton.java
-#      cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassAdvanced_Stub.java
+       cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClass_ProfilingStub.java
+       cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClass_Skeleton.java
+       #cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassAdvanced_Stub.java
        #cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassCallbacks_Stub.java
-       cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassInterface_Skeleton.java -Xlint:unchecked
-       cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassComplete_Stub.java -Xlint:unchecked
-       cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterfaceWithCallBack_Stub.java -Xlint:unchecked
-       cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterface_Skeleton.java -Xlint:unchecked
+#      cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassInterface_Skeleton.java -Xlint:unchecked
+#      cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) TestClassComplete_Stub.java -Xlint:unchecked
+#      cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterfaceWithCallBack_Stub.java -Xlint:unchecked
+#      cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterface_Skeleton.java -Xlint:unchecked
 #      cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterface_CallbackSkeleton.java
 #      cd $(BIN_DIR)/iotpolicy/output_files/Java; $(JAVAC) -cp .:..:../../../$(BIN_DIR) CallBackInterfaceWithCallBack_CallbackStub.java
 
-       cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClassInterface_Skeleton.cpp -o ./TestClassInterface_Skeleton.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
-       cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClassComplete_Stub.cpp -o ./TestClassComplete_Stub.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
+       #cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClassInterface_Skeleton.cpp -o ./TestClassInterface_Skeleton.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
+       #cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./TestClassComplete_Stub.cpp -o ./TestClassComplete_Stub.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
        #cp ./iotrmi/C++/ConcurrentLinkedListQueue.cpp $(BIN_DIR)/iotpolicy/output_files/Cplus
        #cd $(BIN_DIR)/iotpolicy/output_files/Cplus; $(G++) ./ConcurrentLinkedListQueue.cpp -o ./ConcurrentLinkedListQueue.out --std=c++11 -pthread -pg -I../../../../iotjava/iotrmi/C++/
 
@@ -168,9 +170,10 @@ run-java-skeleton:
 
 PHONY += run-java-stub
 run-java-stub:
+       cd ../bin/iotpolicy/output_files/Java; $(JAVA) -cp .:../../../$(BIN_DIR) TestClass_ProfilingStub
 #      cd ../bin/iotpolicy/output_files/Java; $(JAVA) -cp .:../../../$(BIN_DIR) TestClass_Stub
 #      cd ../bin/iotpolicy/output_files/Java; $(JAVA) -cp .:../../../$(BIN_DIR) TestClassAdvanced_Stub
-       cd ../bin/iotpolicy/output_files/Java; $(JAVA) -cp .:../../../$(BIN_DIR) TestClassCallbacks_Stub
+#      cd ../bin/iotpolicy/output_files/Java; $(JAVA) -cp .:../../../$(BIN_DIR) TestClassCallbacks_Stub
 
 PHONY += run-cplus-skeleton
 run-cplus-skeleton:
index be174b80c17a11ce33add0d8e97d96b76517a06a..96827a2450efe4808d6df2f8449a9e424348a60e 100644 (file)
@@ -121,8 +121,8 @@ int main(int argc, char *argv[])
        int portRecv = 6000;
        const char* address = "localhost";
        //const char* address = "192.168.2.191";        // RPi2
-       //const char* skeletonAddress = "128.195.136.170";      // dc-9.calit2.uci.edu
-       const char* skeletonAddress = "128.195.204.132";
+       const char* skeletonAddress = "128.195.136.163";        // dc-2.calit2.uci.edu
+       //const char* skeletonAddress = "128.195.204.132";
        const char* callbackAddress = "128.195.204.132";        // dw-2.eecs.uci.edu (this machine)
        //const char* skeletonAddress = "192.168.2.108";        // RPi1
        //const char* callbackAddress = "192.168.2.191";        // RPi2
@@ -135,6 +135,12 @@ int main(int argc, char *argv[])
        //ports.push_back(43212);
 
        TestClassComplete *tcStub = new TestClassComplete_Stub(portSend, portRecv, skeletonAddress, rev, &bResult);
+       vector<char> in;
+       in.push_back(68);
+       in.push_back(68);
+       vector<char> result = tcStub->getByteArray(in);
+       cout << "Test print: " << in[0] << endl;
+/*
 //     cout << "Getting return value from getShort(): " << tcStub->getShort(1234) << endl;
        //cout << "Getting return value from getShort(): " << tcStub->getShort(4321) << endl;
        //cout << "Getting return value from getShort(): " << tcStub->getShort(5678) << endl;
@@ -150,7 +156,7 @@ int main(int argc, char *argv[])
        //cout << "Return value from callback: " << tcStub->callBack() << endl;
 
        // TODO: we need this while loop at the end to keep the threads running
-       while(true);
+       while(true);*/
 
        return 0;
 }
index 34e47092ae8f52c353a7f8db340903f9aadc0cd6..b4f5c5be618762a516c5693baea97bfe65c727e0 100644 (file)
@@ -173,6 +173,7 @@ int main(int argc, char *argv[])
        int portRecv = 6000;
        //TestClassInterface *tc = new TestClass(argv2, argv3, argv4);
        TestClassInterface *tc = new TestClass(123, 2.345, "test");
+       //TestClassInterface *tc = new TestClassProfiling();
        TestClassInterface_Skeleton *tcSkel = new TestClassInterface_Skeleton(tc, portSend, portRecv);
 
        //delete tc;
diff --git a/iotjava/iotrmi/C++/basics/TestClassProfiling.hpp b/iotjava/iotrmi/C++/basics/TestClassProfiling.hpp
new file mode 100644 (file)
index 0000000..b15f092
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef _TESTCLASS_HPP__
+#define _TESTCLASS_HPP__
+
+#include <iostream>
+#include <thread>
+#include <chrono>
+#include "TestClassInterface.hpp"
+#include "CallBackInterfaceWithCallBack.hpp"
+#include "Enum.hpp"
+#include "Struct.hpp"
+
+using namespace std;
+
+class TestClassProfiling : public TestClassInterface {
+       public:
+               TestClassProfiling();
+
+               vector<char>            getByteArray(vector<char> in);
+
+};
+
+
+TestClassProfiling::TestClassProfiling() {
+
+}
+
+// Arrays
+vector<char> TestClass::getByteArray(vector<char> in) {
+
+       return in;
+}
+
+
+#endif
+
index 5da922909b18cecf038d2dfec61794d74b6196a3..afb287eb8c9745657a8ea43c207cd6873d6b0432 100644 (file)
@@ -11,7 +11,8 @@ int main(int argc, char *argv[])
        TestClassInterface_Skeleton *tcSkel;
 
        int port = 5010;
-       tc = new TestClass(3, 5.0, "7911");
+       //tc = new TestClass(3, 5.0, "7911");
+       tc = new TestClassProfiling();
        string callbackAddress = "128.195.204.132";
        tcSkel = new TestClassInterface_Skeleton(tc, callbackAddress, port);
 
index f9666fe0f8a0668f658c0472a7ef6af139aa7f59..6e9aea4cb56f3473417bfdb9b08cf56eed95bbef 100644 (file)
@@ -323,17 +323,17 @@ public class TestClass implements TestClassInterface {
        // Struct
        public Struct handleStruct(Struct str) {
 
-               System.out.println("Name: " + str.name);
-               System.out.println("Value: " + str.value);
-               System.out.println("Year: " + str.year);
+               //System.out.println("Name: " + str.name);
+               //System.out.println("Value: " + str.value);
+               //System.out.println("Year: " + str.year);
 
 
-               Struct test = new Struct();
-               test.name = "Anonymous";
-               test.value = 1.33f;
-               test.year = 2016;
+               //Struct test = new Struct();
+               //test.name = "Anonymous";
+               //test.value = 1.33f;
+               //test.year = 2016;
 
-               str = test;
+               //str = test;
 
                return str;
        }
diff --git a/iotjava/iotrmi/Java/basics/TestClassProfiling.java b/iotjava/iotrmi/Java/basics/TestClassProfiling.java
new file mode 100644 (file)
index 0000000..4677bcc
--- /dev/null
@@ -0,0 +1,16 @@
+public class TestClassProfiling implements TestClassInterface {
+
+       /**
+        * Constructors
+        */
+       public TestClassProfiling() {
+
+       }
+
+
+       // Arrays
+       public byte[] getByteArray(byte[] in) {
+
+               return in;
+       }
+}
\ No newline at end of file
diff --git a/iotjava/iotrmi/Java/basics/TestClass_ProfilingStub.java b/iotjava/iotrmi/Java/basics/TestClass_ProfilingStub.java
new file mode 100644 (file)
index 0000000..dfe38ef
--- /dev/null
@@ -0,0 +1,67 @@
+import java.util.Arrays;
+import java.util.List;
+import java.util.ArrayList;
+import iotruntime.master.CommunicationHandler;
+
+public class TestClass_ProfilingStub {
+
+       public static void main(String[] args) throws Exception {
+               CommunicationHandler comHan = new CommunicationHandler(true);
+               int numOfPorts = 2;
+               //int[] ports = comHan.getCallbackPorts(numOfPorts);
+
+               //int localportsend = 5011;
+               //int localportrecv = 6011;
+               int portsend = 5000;
+               int portrecv = 6000;
+               //String skeletonAddress = "128.195.136.163";
+               //String skeletonAddress = "128.195.204.132";
+               String skeletonAddress = "192.168.2.108";
+               //String callbackAddress = "128.195.204.132";           // dw-2.eecs.uci.edu (this              machine)
+               String callbackAddress = "192.168.2.191";
+               int rev = 0;
+
+               //TestClassComplete_Stub tcstub = new TestClassComplete_Stub(localportsend, localportrecv, portsend, portrecv, 
+                       //skeletonAddress, rev);
+               TestClassComplete_Stub tcstub = new TestClassComplete_Stub(0, 0, portsend, portrecv, skeletonAddress, rev);
+               //byte[] in1 = { 68, 69 };
+               //int counter = 100;
+               //byte[] in1 = new byte[counter];
+               //for (int i=0; i<counter; i++)
+               //      in1[i] = 68;
+               System.out.println("==== STRUCT ====");
+               Struct str = new Struct();
+               str.name = "Rahmadi";
+               str.value = 0.123f;
+               str.year = 2016;
+               // PROFILING
+               long start = 0;
+               long end = 0;
+               //byte[] returned = null;
+               int exp = 10;
+               long avg = 0;
+               //Struct strRes = null;
+               long longVar = 0;
+               long inVar = 1234;
+               double doubleVar = 0;
+               double inDouble = 1234.1234;
+               for (int i = 0; i < exp; i++) {
+                       start = System.currentTimeMillis();
+                       //start = System.nanoTime();
+                       //System.out.println("Return value: " + Arrays.toString(tcstub.getByteArray(in1)));
+                       //returned = tcstub.getByteArray(in1);
+                       //strRes = tcstub.handleStruct(str);
+                       //longVar = tcstub.getLong(inVar);
+                       doubleVar = tcstub.getDouble(inDouble);
+                       end = System.currentTimeMillis();
+                       //end = System.nanoTime();
+                       //long res = (end - start) / 1000;
+                       long res = (end - start);
+                       System.out.println("\n\n ==> Time: " + res);
+                       //System.out.println("\n\n ==> Time: " + (end - start));
+                       avg = avg + res;
+               }
+               System.out.println("Average: " + (avg / exp));
+       }
+
+}
index c85842d205bac945c03d5ac4b6d7cd9f22597613..0e83e7514745eb1565be8aed9bf4266ab4766acf 100644 (file)
@@ -7,7 +7,8 @@ public class TestClass_Skeleton {
                int portsend = 5000;
                int portrecv = 6000;
                String callbackAddress = InetAddress.getLocalHost().getHostAddress();
-               TestClass tc = new TestClass(3, 5f, "7911");
+               //TestClassProfiling tc = new TestClassProfiling();
+               TestClass tc = new TestClass();
                TestClassInterface_Skeleton tcSkel = new TestClassInterface_Skeleton(tc, portsend, portrecv);
        }
 }
diff --git a/localconfig/iotpolicy/development/testclasspolicy_profiling.pol b/localconfig/iotpolicy/development/testclasspolicy_profiling.pol
new file mode 100644 (file)
index 0000000..df74e0d
--- /dev/null
@@ -0,0 +1,11 @@
+public interface TestClassInterface {
+
+       public byte[] getByteArray(byte in[]);
+
+       capability All {
+               description = "All";
+               method = "getByteArray(byte in[])";
+       }
+}
+
+
diff --git a/localconfig/iotpolicy/development/testclassrequires_profiling.pol b/localconfig/iotpolicy/development/testclassrequires_profiling.pol
new file mode 100644 (file)
index 0000000..fb72e24
--- /dev/null
@@ -0,0 +1 @@
+requires TestClassInterface with All as interface TestClassComplete;
\ No newline at end of file