Skip to content

Commit 54bab8c

Browse files
authored
use machine architecture as default SDK architecture (dotnet#2374)
1 parent 8b50e40 commit 54bab8c

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

scripts/benchmarks_monthly.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
monthly manual performance runs.
77
'''
88

9+
from performance.common import get_machine_architecture
910
from performance.logger import setup_loggers
1011
from argparse import ArgumentParser, ArgumentTypeError
1112
from datetime import datetime
@@ -61,7 +62,7 @@ def add_arguments(parser: ArgumentParser) -> ArgumentParser:
6162
'--architecture',
6263
dest='architecture',
6364
choices=['x64', 'x86', 'arm64', 'arm'],
64-
default='x64',
65+
default=get_machine_architecture(),
6566
help='Specifies the SDK processor architecture')
6667

6768
parser.add_argument(

scripts/dotnet.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from urllib.request import urlopen
2323
from time import sleep
2424

25+
from performance.common import get_machine_architecture
2526
from performance.common import get_repo_root_path
2627
from performance.common import get_tools_directory
2728
from performance.common import push_dir
@@ -845,7 +846,7 @@ def __add_arguments(parser: ArgumentParser) -> ArgumentParser:
845846
raise TypeError('Invalid parser.')
846847

847848
SUPPORTED_ARCHITECTURES = [
848-
'x64', # Default architecture
849+
'x64',
849850
'x86',
850851
'arm',
851852
'arm64',
@@ -854,7 +855,7 @@ def __add_arguments(parser: ArgumentParser) -> ArgumentParser:
854855
'--architecture',
855856
dest='architecture',
856857
required=False,
857-
default=SUPPORTED_ARCHITECTURES[0],
858+
default=get_machine_architecture(),
858859
choices=SUPPORTED_ARCHITECTURES,
859860
help='Architecture of DotNet Cli binaries to be installed.'
860861
)

scripts/performance/common.py

+15
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,26 @@
1313
from subprocess import Popen
1414
from subprocess import STDOUT
1515
from io import StringIO
16+
from platform import machine
1617

1718
import os
1819
import sys
1920

2021

22+
def get_machine_architecture():
23+
machineArch = machine().lower()
24+
# values taken from https://stackoverflow.com/a/45125525/5852046
25+
if machineArch == 'amd64' or machineArch == 'x86_64' or machineArch == 'x64':
26+
return 'x64'
27+
elif machineArch == 'arm64' or machineArch == 'aarch64' or machineArch == 'aarch64_be' or machineArch == 'armv8b' or machineArch == 'armv8l':
28+
return 'arm64'
29+
elif machineArch == 'arm32' or machineArch == 'aarch32' or machineArch == 'arm':
30+
return 'arm'
31+
elif machineArch == 'i386' or machineArch == 'i486' or machineArch == 'i686':
32+
return 'x86'
33+
else:
34+
return 'x64' # Default architecture
35+
2136
def iswin():
2237
return sys.platform == 'win32'
2338

0 commit comments

Comments
 (0)