-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparallel_test.fl
More file actions
79 lines (60 loc) · 2.11 KB
/
parallel_test.fl
File metadata and controls
79 lines (60 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Test de Ejecución Paralela
# Python, JavaScript y C++ se ejecutan SIMULTÁNEAMENTE
@parallel
print("=" * 60)
print("MODO PARALELO - FLOW v2.0")
print("=" * 60)
print("\n[Python] Iniciando procesamiento paralelo...")
print("[Python] Simulando tarea de I/O (lectura de archivos)...")
import time
import json
# Simular lectura de archivos (I/O bound)
for i in range(5):
print(f"[Python] Leyendo archivo {i+1}/5...")
time.sleep(0.3) # Simula I/O
# Guardar resultado
data = {'files_read': 5, 'total_size': 1024}
with open('python_result.json', 'w') as f:
json.dump(data, f)
print("[Python] OK Procesamiento Python completado")
# JavaScript se ejecuta EN PARALELO con Python
fn processData():
console.log("\n[JavaScript] Iniciando transformación paralela...");
console.log("[JavaScript] Simulando tarea de CPU (transformación)...");
// Simular procesamiento CPU-bound
for (let i = 0; i < 5; i++) {
console.log(`[JavaScript] Transformando batch ${i+1}/5...`);
// Simular trabajo CPU
let sum = 0;
for (let j = 0; j < 10000000; j++) {
sum += Math.sqrt(j);
}
}
const fs = require('fs');
fs.writeFileSync('js_result.json', JSON.stringify({
batches_processed: 5,
total_records: 50000
}));
console.log("[JavaScript] OK Transformacion JavaScript completada");
processData()
# C++ también se ejecuta EN PARALELO
cpp
#include <chrono>
#include <thread>
std::cout << "\n[C++] Iniciando cálculos paralelos..." << std::endl;
std::cout << "[C++] Simulando tarea de CPU intensiva..." << std::endl;
// Simular cálculos pesados
for (int i = 0; i < 5; ++i) {
std::cout << "[C++] Calculando iteración " << (i+1) << "/5..." << std::endl;
// Simular trabajo CPU intensivo
long long sum = 0;
for (long long j = 0; j < 100000000; ++j) {
sum += j;
}
std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
std::ofstream result("cpp_result.txt");
result << "iterations:5\nsum:4999999950000000\n";
result.close();
std::cout << "[C++] OK Calculos C++ completados" << std::endl;
end