import time
from dask.distributed import Client
client = Client('localhost:8786')
print(client)

N = 5 # length array

def inc(x):
    time.sleep(1) # Time in seconds
    return x + 1

c = client.submit(inc, 0) # Send 1 task to cluster, return 1 future
c = c.result() # block until work finishes, then gather result
#print(c)
array = [0 for i in range(N)]

y_s = []
s = time.time()
for i in range(N):  # Sequential version to inc
    y_s.append(inc(array[i]))

f = time.time()
print('Time sequential: '+str(f-s)) 
print(y_s)

s = time.time()
x = client.map(inc, array) # Send list task, return future list
y = client.gather(x)
f = time.time()

print('Time distributed: '+str(f-s)) 
print(y)



9d68b49c1f193d2a2e352587daae13891f1c9242
<mask token>

<mask token>
print(client)
<mask token>


def inc(x):
    time.sleep(1)
    return x + 1


<mask token>
for i in range(N):
    y_s.append(inc(array[i]))
<mask token>
print('Time sequential: ' + str(f - s))
print(y_s)
<mask token>
print('Time distributed: ' + str(f - s))
print(y)

<mask token>
client = Client('localhost:8786')
print(client)
N = 5


def inc(x):
    time.sleep(1)
    return x + 1


c = client.submit(inc, 0)
c = c.result()
array = [(0) for i in range(N)]
y_s = []
s = time.time()
for i in range(N):
    y_s.append(inc(array[i]))
f = time.time()
print('Time sequential: ' + str(f - s))
print(y_s)
s = time.time()
x = client.map(inc, array)
y = client.gather(x)
f = time.time()
print('Time distributed: ' + str(f - s))
print(y)

import time
from dask.distributed import Client
client = Client('localhost:8786')
print(client)
N = 5


def inc(x):
    time.sleep(1)
    return x + 1


c = client.submit(inc, 0)
c = c.result()
array = [(0) for i in range(N)]
y_s = []
s = time.time()
for i in range(N):
    y_s.append(inc(array[i]))
f = time.time()
print('Time sequential: ' + str(f - s))
print(y_s)
s = time.time()
x = client.map(inc, array)
y = client.gather(x)
f = time.time()
print('Time distributed: ' + str(f - s))
print(y)

import time
from dask.distributed import Client
client = Client('localhost:8786')
print(client)

N = 5 # length array

def inc(x):
    time.sleep(1) # Time in seconds
    return x + 1

c = client.submit(inc, 0) # Send 1 task to cluster, return 1 future
c = c.result() # block until work finishes, then gather result
#print(c)
array = [0 for i in range(N)]

y_s = []
s = time.time()
for i in range(N):  # Sequential version to inc
    y_s.append(inc(array[i]))

f = time.time()
print('Time sequential: '+str(f-s)) 
print(y_s)

s = time.time()
x = client.map(inc, array) # Send list task, return future list
y = client.gather(x)
f = time.time()

print('Time distributed: '+str(f-s)) 
print(y)


