-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from NCAR/deep
Numba versions of T-Digest quantile and cdf
- Loading branch information
Showing
4 changed files
with
204 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import matplotlib | ||
matplotlib.use('agg') | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import psutil | ||
import xarray as xr | ||
mem = [] | ||
def get_data(): | ||
return np.zeros((1000, 50, 50), dtype=np.float32) | ||
data = get_data() | ||
for i in range(data.shape[0]): | ||
data[i] = np.random.random((50, 50)) | ||
mem.append(psutil.virtual_memory()[1]) | ||
mem.append(psutil.virtual_memory()[1]) | ||
xd = xr.DataArray(data) | ||
mem.append(psutil.virtual_memory()[1]) | ||
plt.plot(mem) | ||
plt.savefig("mem_profile.png", dpi=200, bbox_inches="tight") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from scipy.stats import norm | ||
from scipy.special import ndtri | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import psutil | ||
import gc | ||
|
||
process = psutil.Process() | ||
n_elements = 301 | ||
mem_vals = np.zeros(n_elements) | ||
mem_vals[0] = process.memory_info().rss / 1e6 | ||
for i in range(1, n_elements): | ||
x = np.random.random(size=(100, 50, 50)) | ||
ppf_val = ndtri(x) | ||
mem_vals[i] = process.memory_info().rss / 1e6 | ||
gc.collect() | ||
plt.plot(mem_vals[1:] - mem_vals[0], label="ndtri") | ||
mem_vals = np.zeros(n_elements) | ||
mem_vals[0] = process.memory_info().rss / 1e6 | ||
|
||
for i in range(1, n_elements): | ||
x = np.random.random(size=(100, 50, 50)) | ||
ppf_val = norm.ppf(x) | ||
mem_vals[i] = process.memory_info().rss / 1e6 | ||
gc.collect() | ||
plt.plot(mem_vals[1:] - mem_vals[0], label="norm.ppf") | ||
mem_vals = np.zeros(n_elements) | ||
mem_vals[0] = process.memory_info().rss / 1e6 | ||
for i in range(1, n_elements): | ||
x = np.random.random(size=(100, 50, 50)) | ||
mem_vals[i] = process.memory_info().rss / 1e6 | ||
gc.collect() | ||
plt.plot(mem_vals[1:] - mem_vals[0], label="control") | ||
plt.xlabel("Iterations") | ||
plt.ylabel("Memory usage (MB)") | ||
plt.legend() | ||
plt.savefig("norm_usage_tracking.png", dpi=200, bbox_inches="tight") |