Skip to content

Commit

Permalink
Added Raspberry Pi power results
Browse files Browse the repository at this point in the history
  • Loading branch information
thepercyj committed Aug 27, 2024
1 parent 33ede4d commit 8528145
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 234 deletions.
Binary file modified dist/ulto-1.0.0-py3.9.egg
Binary file not shown.
165 changes: 7 additions & 158 deletions logs/performance_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,7 @@ Number of Threads Used: 1
Assignments: 2496
Evaluations: 7985
Reversals: 0
Memory Usage: 0.35 MB

Execution Details (2024-08-02 15:39:40.411502):
Execution Time: 0.07653498649597168 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 7985
Reversals: 0
Memory Usage: 0.35 MB

Execution Details (2024-08-02 15:41:11.938454):
Execution Time: 0.11420369148254395 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 7985
Reversals: 0
Memory Usage: 0.35 MB
Memory Usage: 0.3448028564453125 MB

~~~~~~~ After Malloc and LazyEval ~~~~~~~~~

Expand All @@ -34,80 +18,9 @@ Evaluations: 5992
Reversals: 0
Memory Usage: 0.3448028564453125 MB

Execution Details (2024-08-02 22:07:05.977011):
Execution Time: 0.7262997627258301 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.3448028564453125 MB

Execution Details (2024-08-02 22:07:16.301243):
Execution Time: 0.749596118927002 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.3448028564453125 MB

Execution Details (2024-08-02 22:08:16.982171):
Execution Time: 0.715092658996582 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.3448028564453125 MB

Execution Details (2024-08-02 22:15:35.256445):
Execution Time: 0.741351842880249 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.3448028564453125 MB

Execution Details (2024-08-02 22:15:50.793974):
Execution Time: 0.745030403137207 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.3448028564453125 MB

Execution Details (2024-08-02 22:15:56.871851):
Execution Time: 0.747645378112793 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.3448028564453125 MB

Execution Details (2024-08-02 22:19:01.302415):
Execution Time: 0.7686457633972168 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 7985
Reversals: 0
Memory Usage: 0.34860992431640625 MB

Execution Details (2024-08-02 22:19:20.378415):
Execution Time: 0.7334673404693604 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 7985
Reversals: 0
Memory Usage: 0.34860992431640625 MB

~~~~ Batch Profiling, Memory Pooling, Inline Interpreter Optimisation ~~~~~~~~~

Execution Details (2024-08-02 22:21:31.183212):
Execution Time: 0.10274887084960938 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 7985
Reversals: 0
Memory Usage: 0.35 MB

Execution Details (2024-08-02 22:23:22.602039):
Execution Time: 0.08441734313964844 seconds
Number of Threads Used: 1
Expand All @@ -116,77 +29,13 @@ Evaluations: 5992
Reversals: 0
Memory Usage: 0.3448028564453125 MB

Execution Details (2024-08-02 23:47:14.355121):
Execution Time: 0.06659555435180664 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.3448028564453125 MB

Execution Details (2024-08-03 00:23:13.105583):
Execution Time: 0.09912323951721191 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.344818115234375 MB

Execution Details (2024-08-03 00:23:34.983307):
Execution Time: 0.09803009033203125 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.344818115234375 MB

Execution Details (2024-08-03 00:23:58.854947):
Execution Time: 0.07106328010559082 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.344818115234375 MB

Execution Details (2024-08-03 00:24:08.177109):
Execution Time: 0.032892465591430664 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.344818115234375 MB

Execution Details (2024-08-03 10:29:02.444935):
Execution Time: 0.021917343139648438 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.3448152542114258 MB

~~~~~~~~~ After Logstack with Prune Operations Implementation ~~~~~~~~~~

Execution Details (2024-08-03 11:26:26.563407):
Execution Time: 0.021305084228515625 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.0009584426879882812 MB
~~~~~~~~~ After Logstack with Prune Operations Implementation and Offloading Heavy Operations to C compiler~~~~~~~~~~

Execution Details (2024-08-06 18:37:08.899915):
Execution Time: 0.03003692626953125 seconds
Execution Time: 0.2825326919555664 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.0009584426879882812 MB

Execution Details (2024-08-06 18:38:18.816277):
Execution Time: 0.03099846839904785 seconds
Number of Threads Used: 1
Assignments: 2496
Evaluations: 5992
Reversals: 0
Memory Usage: 0.0009584426879882812 MB

Assignments: 1185
Evaluations: 8542
Reversals: 1996
Memory Usage: 0.0008668899536132812 MB
53 changes: 14 additions & 39 deletions src/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ def detect_eager_vars(self):
"""
Detects eager variables based on the profiling data.
"""
# threshold set to 3 to avoid inaccuracy of dealing hotspots, can shift it to 5 for reducing overhead but for now is good. can be tweaked based on nature of application.
# threshold set to 3 to avoid inaccuracy of dealing hotspots, can shift it to 5 for reducing overhead but for
# now is good. can be tweaked based on nature of application.
threshold = 3
for var, count in self.profiling_data.items():
if count > threshold:
Expand Down Expand Up @@ -344,7 +345,8 @@ def execute_assignment(self, node):
self.assignments += 1
_, var_name, value = node

# Considering hybrid approach since, some programs developed can have circular dependency. Hence, based on the source code profile eager and lazy accordingly.
# Considering hybrid approach since, some programs developed can have circular dependency. Hence, based on the
# source code profile eager and lazy accordingly.
# for eg: "i = i + 1" meets the requirement of circular dependency causing infinite loops if lazily evaluated.
if var_name in self.eager_vars:
evaluated_value = self.evaluate_expression(value)
Expand Down Expand Up @@ -821,42 +823,6 @@ def execute_revtrace(self, node):
else:
print(f"No state found for {var_name} at index {index}")

def get_previous_value(self, var_name, index):
"""
Retrieves the previous value of a variable from the log stack by index.
Args:
var_name (str): The name of the variable.
index (int): The index of the state to retrieve.
Returns:
The previous value of the variable or None if not found.
"""
values = []
while len(values) < index:
previous_value = self.logstack.pop(var_name)
if previous_value is None:
break
values.append(previous_value)

# Restoring the log stack state to tracepath assignment history
for value in reversed(values):
self.logstack.push(var_name, value)

if index <= len(values):
return values[index - 1]
else:
return None

def error(self, message):
"""
Raises an error with the given message.
Args:
message (str): The error message.
"""
raise Exception(f'Execution error: {message}')

def prune_logstack(self):
self.logstack.prune()
if self.logstack.get_memory_usage() > 50:
Expand Down Expand Up @@ -897,7 +863,7 @@ def log_execution_details(self, start_time, end_time):
"""
num_threads = threading.active_count()
execution_time = end_time - start_time
with open("./logs/execution_log.txt", "a") as log_file:
with open("execution_log.txt", "a") as log_file:
log_file.write(f"Execution Details ({datetime.now()}):\n")
log_file.write(f"Execution Time: {execution_time} seconds\n")
log_file.write(f"Number of Threads Used: {num_threads}\n")
Expand All @@ -906,3 +872,12 @@ def log_execution_details(self, start_time, end_time):
log_file.write(f"Reversals: {self.reversals}\n")
log_file.write(f"Memory Usage: {self.get_memory_usage()} MB\n")
log_file.write("\n")

def error(self, message):
"""
Raises an error with the given message.
Args:
message (str): The error message.
"""
raise Exception(f'Execution error: {message}')
12 changes: 4 additions & 8 deletions src/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ def parse_if(self):
self.consume('IF')
condition = self.parse_expression()

# Handle compound conditions
while self.current_token and self.current_token[0] in ['AND', 'OR']:
op = self.current_token[0].lower()
self.advance()
Expand All @@ -258,15 +257,13 @@ def parse_if(self):
elif_branches = []
false_branch = []

# Handle elif branches
while self.current_token and self.current_token[0] == 'ELIF':
self.advance() # Move past 'elif'
self.advance()
elif_condition = self.parse_expression()
self.consume('COLON')
elif_branch = self.parse_block()
elif_branches.append((elif_condition, elif_branch))

# Handle else branch
if self.current_token and self.current_token[0] == 'ELSE':
self.consume('ELSE')
self.consume('COLON')
Expand All @@ -287,7 +284,7 @@ def parse_for(self):
self.consume('IN')

if self.current_token[0] == 'LBRACKET':
iterable = self.consume_value() # This will consume the entire list
iterable = self.consume_value()

elif self.current_token[0] == 'RANGE':
self.consume('RANGE')
Expand All @@ -302,15 +299,14 @@ def parse_for(self):
self.consume('COMMA')
step_value = self.parse_expression()
else:
end_value = start_value # Treat single parameter as range(end)
start_value = ('NUMBER', 0) # Default start at 0
end_value = start_value
start_value = ('NUMBER', 0)
step_value = None

self.consume('RPAREN')
iterable = ('range', start_value, end_value, step_value)

else:
# Assume it's a variable holding an iterable
iterable = self.parse_expression()

self.consume('COLON')
Expand Down
Loading

0 comments on commit 8528145

Please sign in to comment.