# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3 (ipykernel)
#     language: python
#     name: python3
# ---

# # Testing the performance of `dask.visualize` at various number of nodes

# ### Assumptions made by me
# - 100 nodes of dask.array are the same as dask.dataframe or any other kind of Dask object
# - This test was conducted in a Python 3.8 Linux Environment and may/may not reflect Graphviz's performance reports elsewhere
#
# ### Device Specifications
# ```
# Architecture:                    x86_64
# CPU op-mode(s):                  32-bit, 64-bit
# Byte Order:                      Little Endian
# Address sizes:                   39 bits physical, 48 bits virtual
# CPU(s):                          8
# On-line CPU(s) list:             0-7
# Thread(s) per core:              2
# Core(s) per socket:              4
# Socket(s):                       1
# NUMA node(s):                    1
# Vendor ID:                       GenuineIntel
# CPU family:                      6
# Model:                           142
# Model name:                      Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
# ```
#
# ```
# frey@dhokla 
# ----------- 
# OS: Pop!_OS 20.04 LTS x86_64 
# Host: HP Pavilion Laptop 15-cs1xxx 
# Kernel: 5.11.0-7614-generic 
# Uptime: 14 hours, 56 mins 
# Packages: 2664 (dpkg), 12 (flatpak) 
# Shell: zsh 5.8 
# Resolution: 1920x1080 
# DE: GNOME 
# WM: Mutter 
# WM Theme: Pop 
# Theme: Nordic-darker [GTK2/3] 
# Icons: Fluent [GTK2/3] 
# Terminal: x-terminal-emul 
# CPU: Intel i7-8565U (8) @ 4.600GHz 
# GPU: NVIDIA GeForce GTX 1050 Mobile 
# GPU: Intel UHD Graphics 620 
# Memory: 7018MiB / 15894MiB
# ```
#
# ```
#  active environment : dask-dev
#     active env location : /home/frey/miniconda3/envs/dask-dev
#             shell level : 2
#        user config file : /home/frey/.condarc
#  populated config files : /home/frey/.condarc
#           conda version : 4.10.1
#     conda-build version : not installed
#          python version : 3.8.5.final.0
#        virtual packages : __cuda=11.2=0
#                           __linux=5.11.0=0
#                           __glibc=2.31=0
#                           __unix=0=0
#                           __archspec=1=x86_64
#        base environment : /home/frey/miniconda3  (writable)
#       conda av data dir : /home/frey/miniconda3/etc/conda
#   conda av metadata url : https://repo.anaconda.com/pkgs/main
#            channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
#                           https://repo.anaconda.com/pkgs/main/noarch
#                           https://repo.anaconda.com/pkgs/r/linux-64
#                           https://repo.anaconda.com/pkgs/r/noarch
#           package cache : /home/frey/miniconda3/pkgs
#                           /home/frey/.conda/pkgs
#        envs directories : /home/frey/miniconda3/envs
#                           /home/frey/.conda/envs
#                platform : linux-64
#              user-agent : conda/4.10.1 requests/2.24.0 CPython/3.8.5 Linux/5.11.0-7614-generic pop/20.04 glibc/2.31
#                 UID:GID : 1000:1000
#              netrc file : None
#            offline mode : False
# ```

import dask.array as da

# +
# 10 nodes

ten = da.ones((1,10), chunks=(1,1))

# %timeit ten.visualize()

# +
# 100 nodes

hundred = da.ones((1,100), chunks=(1,1))

# %timeit hundred.visualize()

# +
# 500 nodes

five_hundred = da.ones((1,500), chunks=(1,1))

# %timeit five_hundred.visualize()

# +
# 1000 nodes

thousand = da.ones((1,1000), chunks=(1,1))

# %timeit thousand.visualize()

# +
# 2000 nodes
105226460
two_thousand = da.ones((1,2000), chunks=(1,1))

# %timeit two_thousand.visualize()

# +
# 5000 nodes

five_thousand = da.ones((1,5000), chunks=(1,1))

# %timeit five_thousand.visualize()
# -

# ## Analysis
#
# | Nodes |    10   |   100  |   500  |  1000  |   2000  |   5000   |
# |:-----:|:-------:|:------:|:------:|:------:|:-------:|:--------:|
# |  Time | 32.3 ms | 113 ms | 372 ms | 522 ms | 2006 ms | 42000 ms |
#
# ## Equation
# `(Time) = 0.002373638*(Nodes)^2 - 3.641743*(Nodes) + 762.195`
#
# ## Plot
# ![Graph](https://i.imgur.com/uRdbOzi.png?raw=true)
# ![Graph](https://i.imgur.com/hc6or7J.png?raw=true)
# ![Graph](https://i.imgur.com/RBhTDpb.png?raw=true)
# ![Graph](https://i.imgur.com/nUTtWHE.png?raw=true)

StarcoderdataJupyterScriptsDedupFiltered